fix(project): reject empty/whitespace-only --name in create and update#36
Open
lxcario wants to merge 1 commit into
Open
fix(project): reject empty/whitespace-only --name in create and update#36lxcario wants to merge 1 commit into
lxcario wants to merge 1 commit into
Conversation
project create/update validated --name with the action handler's if (!name) check, which a whitespace-only string passes (a non-empty string is truthy). The blank name was then sent verbatim, creating a junk-named project. The sibling est create already rejects this via the requireString whitespace guard (dogfood P1 fix TestSprite#1); this aligns project create/update with that behavior. Adds 2 regression tests.
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.
What
testsprite project createandproject updateaccept a whitespace-only--name(e.g.--name " ") and send it to the backend verbatim, creating a blank-named project.Why this matters
A whitespace-only name produces a junk project record that's effectively unidentifiable in
project listand the dashboard. The siblingtest createalready rejects this input, so the two write paths behave inconsistently for the same kind of value.Reproduction
Root cause
src/commands/project.ts. The command action validates the name withif (!cmdOpts.name), which a whitespace-only string passes (a non-empty string is truthy), andrunCreate/runUpdateonly check the upper length bound:There is no lower-bound / whitespace check, so
" "flows straight into the request body.Fix
Reject empty / whitespace-only names in both
runCreateandrunUpdate, before the existing length checks:This mirrors the existing
requireStringwhitespace guard insrc/lib/validate.tsthattest createalready uses (added as "dogfood P1 fix #1" to stop junk records reaching the backend) — the project path just wasn't going through it.Tests
Added 2 tests to
src/commands/project.test.ts(one forrunCreate, one forrunUpdate) asserting a whitespace-only--namerejects withVALIDATION_ERROR/ exit 5 and makes no network call. Both fail onmainbefore this fix and pass after.main):Tests 16 failed | 1359 passed | 72 skippedTests 16 failed | 1361 passed | 72 skipped(+2 new tests)The 16 failures are pre-existing and environment-specific (Windows path/line-ending), unrelated to this change — see #4.
Verification
npm test: same 16 pre-existing (environment-specific) failures as baseline, zero newnpm run typecheck: passnpm run lint: pass