Skip to content

fix(#282): return 400 for invalid status/type enum params on volunteer opportunity list#534

Open
nadavosa wants to merge 2 commits into
developfrom
282-invalid-data-400
Open

fix(#282): return 400 for invalid status/type enum params on volunteer opportunity list#534
nadavosa wants to merge 2 commits into
developfrom
282-invalid-data-400

Conversation

@nadavosa

Copy link
Copy Markdown
Collaborator

Summary

  • Validates status and type query params against their respective enums before passing to TypeORM
  • Throws BadRequestError (400) instead of letting an invalid value reach the DB and cause a 500

Related

Test plan

  • GET /volunteer/6/opportunity?status=post returns 400 with a descriptive message
  • GET /volunteer/6/opportunity?status=opp-active&type=vol-regular returns 200

🤖 Generated with Claude Code

"/",
{
schema: {
querystring: volunteerOpportunityListQuerySchema,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need code below for validation. pls update querystring schema instead

nadavosa and others added 2 commits May 22, 2026 17:11
…rn 400

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…enforce valid status/type

AJV validates `status` and `type` against the OpportunityStatusType and
VolunteerStateTypeType enums via getRef() in volunteerOpportunityListQuerySchema,
so the manual BadRequestError guards in the route handler are redundant.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nadavosa nadavosa force-pushed the 282-invalid-data-400 branch from 9b055d8 to d7a7667 Compare May 22, 2026 15:11

@nadavosa nadavosa left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed — removed the manual BadRequestError guards for status and type. The AJV schema (volunteerOpportunityListQuerySchema) already validates both fields against their respective enums via getRef(), so the route-level checks were redundant. Also rebased onto develop.

@nadavosa

Copy link
Copy Markdown
Collaborator Author

Addressed — removed the manual BadRequestError guards for status and type. The AJV schema (volunteerOpportunityListQuerySchema) already validates both fields against their respective enums via getRef(), so the route-level checks were redundant. Also rebased onto develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wrong http status code for invalid data

2 participants