fix(rosettify): validate plan names on writes - #285
Conversation
Signed-off-by: Shin <128954611+shin4141@users.noreply.github.com>
|
Thanks @shin4141. To fix:
Not yours, no action needed: What checks out — the real risk, and it held:
No version bump needed from you — the companion PR carries rosettify 3.2.2. |
Signed-off-by: Shin <128954611+shin4141@users.noreply.github.com>
|
Thanks for flagging this. I added the non-string guard before .trim() and regression coverage for name: 123 and name: {} across the validator and create/upsert paths. Both now return size_limit_exceeded instead of internal_error. Focused tests, typecheck, build, and the full suite—60 files / 1,578 tests—pass in 522eda7. Ready for re-review. |
isolomatov-gd
left a comment
There was a problem hiding this comment.
Thank you @shin4141 — both items done, and the guard is confirmed by execution across three trees: at your pre-fix commit 123/{}/[] returned internal_error: name.trim is not a function; on main they silently persisted name=123; on your head all three return size_limit_exceeded on both the CLI and --mcp, across all four write paths, with no leftover file and no .bakNNN. null and omitted still give "Unnamed Plan".
typeof name !== "string" is the right layer here — core.ts:389-397 already uses exactly that defensive idiom on parsed JSON, and there is no runtime schema layer to move it into. Widening the signature to unknown is correct for a runtime guard. Your tests assert the specific error code plus the absence of a written file, which is the right shape.
Two citations in my earlier comment were wrong, though the substance stood: the error-code enumeration is FR-PLAN-0021, not FR-PLAN-0022 (which is "No-Args Shows Help"), and internal_error is in fact documented, in FR-SHRD-0004. Sorry for the misdirection.
1578 tests pass, branches 90.67% against the 90% gate. No version bump needed from you — this branch's companion PR carries rosettify 3.2.2.
Approved.
Summary
validatePlanNamehelperUnnamed Plandefault when a name is omittedWhy
validatePlanNamealready enforced the required non-empty plan name, but the create and upsert paths only calledvalidateSizeLimits. Its truthy length guard allowed empty or whitespace-only names to be written. Reusing the existing helper in the shared validation path keeps the name rules in one place.Validation
npm run typechecknpm test— 60 files, 1,572 tests passedgit diff --checkFixes #225
Checklist
AI assistance
AI assistance was used to inspect the issue, implement the focused change, and run validation. I reviewed every changed line.