Reject empty company/role in submit-application route - #1
Open
Powerworks wants to merge 1 commit into
Open
Powerworks wants to merge 1 commit into
Powerworks wants to merge 1 commit into
Conversation
POST /applications previously accepted empty-string company and role values since bodySchema only checked presence, not content. Add minLength: 1 to both fields so Fastify's existing schema validation rejects empty strings the same way it already rejects missing required fields, mapping to the existing 400 InvalidRequest response. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /applicationsaccepted empty-stringcompanyandrolevalues becausebodySchemainsrc/slices/submit-application/route.tsonly checked field presence, not content.minLength: 1to thecompanyandrolefields inbodySchema. This routes through Fastify's existing schema validation (no new error class or decider guard), which already maps validation failures to the existing 400InvalidRequestresponse used for missing required fields.route.spec.tscovering an empty-stringcompanybeing rejected with 400.Why
An empty string is not a meaningful company or role name, and previously slipped past validation to create an application shell with no real identifying data.
Test plan
npm test(vitest, using testcontainers Postgres).src/slices/submit-application/route.spec.ts, up from 2, covering the new empty-string rejection case).🤖 Generated with Claude Code