Skip to content

fix: check concerto validation result before calling templateFromDatabase#154

Open
JayDS22 wants to merge 1 commit intoaccordproject:mainfrom
JayDS22:jay/138/fix-template-validation-order
Open

fix: check concerto validation result before calling templateFromDatabase#154
JayDS22 wants to merge 1 commit intoaccordproject:mainfrom
JayDS22:jay/138/fix-template-validation-order

Conversation

@JayDS22
Copy link
Copy Markdown

@JayDS22 JayDS22 commented Mar 28, 2026

Summary

Fixes #138

Problem

In server/handlers/templates.ts, the templateValidation function called
templateFromDatabase(body) before checking whether concertoValidation
returned success or failure. When the body was invalid, templateFromDatabase
threw a deserialization error that got caught by the outer catch block,
masking the structured validation error that concertoValidation had already
produced.

Fix

Moved templateFromDatabase to after the result.success check. Invalid
payloads now return the Concerto validation error directly. Template
deserialization only runs on validated data.

How to test

  1. POST to /templates with a body missing required fields
  2. Before: 500 with a deserialization error
  3. After: 400 with structured validation details

Discord: Jay Guwalani (jayds22)

…base

templateFromDatabase was called unconditionally before the validation
result was inspected. When the body contained invalid data, this caused
a raw deserialization exception that masked the structured validation
error from concertoValidation.

Moved the templateFromDatabase call to after the success check so that
invalid payloads return the correct validation error.

Fixes accordproject#138

Signed-off-by: Jay Guwalani <guwalanijj@gmail.com>
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label Apr 13, 2026
@JayDS22
Copy link
Copy Markdown
Author

JayDS22 commented Apr 13, 2026

@github-actions unstale

@github-actions github-actions Bot removed the Stale label Apr 15, 2026
@github-actions
Copy link
Copy Markdown

This PR is stale because it has been open 15 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions Bot added the Stale label Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: templateValidation calls templateFromDatabase before concerto validation success is checked

1 participant