fix(office): reject empty slug on skill update - #3509
Conversation
PATCH /api/v1/skills/:id with {"slug":""} previously short-circuited
past the well-formedness check and persisted an empty slug, producing a
skill row that skillslug delivery silently drops. Empty is now treated
as not well-formed like any other invalid slug and rejected with 400;
omitting the field is still the only way to leave the slug unchanged.
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: QUIET Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: QUIET Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughSkill updates now reject explicit empty slugs. Updates that omit the slug preserve the existing value. Service and HTTP handler tests cover both behaviors. ChangesSkill slug update behavior
Priority: ⬇️ Low — Defer this change because it is limited to rejecting empty skill slugs while preserving omitted-slug updates. Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Skill updates now reject explicit empty slugs while preserving existing slugs when the field is omitted. The covered behavior is ready to merge. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. A rabbit checks the slug at night Comment |
|
| Filename | Overview |
|---|---|
| apps/backend/internal/office/skills/service.go | Removes the empty-slug validation bypass so empty values are rejected by the shared well-formedness check. |
| apps/backend/internal/office/skills/handler_test.go | Adds end-to-end handler coverage for explicit-empty rejection, unchanged persistence, and omitted-field semantics. |
| apps/backend/internal/office/skills/service_test.go | Adds focused service coverage proving that an empty slug is rejected rather than normalized or coerced. |
Reviews (1): Last reviewed commit: "fix(office): reject empty slug on skill ..." | Re-trigger Greptile
|
Claude finished @nova28's task in 2m 17s —— View job Code Review
FindingsSuggestion (recommended, doesn't block)
What this PR does well
Summary
Verdict: Ready to merge |
|
Addressed in commit a20ece6: moved the empty-slug service regression into a focused test file and added handler coverage for another malformed slug. The Office skills package passes 113 tests. Thanks for the contribution. Fresh CI is now running on the pushed head. |
A row with an already-empty stored slug (reachable via config-import, which bypasses slug validation) rejected any update that omitted slug, since ValidateSkillUpdate now validates the resulting state strictly. Generate a canonical slug from the skill name before validating when the request itself does not ask to change the slug. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The self-heal added in the previous round could generate a name-derived slug that collided with another skill, causing an unrelated content-only edit to be rejected with a uniqueness error the caller never asked about. Move the heal into the service layer and only apply it when a free candidate is found; otherwise leave the stored empty slug untouched so the request still succeeds. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Thanks for the review and for tightening up the test coverage in a20ece6 — I've built on top of it (not replaced it) with two more commits that close a related gap: The gap: The fix (
Added Happy to drop this if you'd rather ship the simpler reject-only version and handle the stored-empty-slug case separately — let me know. |
Tip
PR walkthrough: Open the visual walkthrough
fix(office): reject empty slug on skill update
PATCH /api/v1/skills/:id with {"slug":""} previously short-circuited
past the well-formedness check and persisted an empty slug, producing a
skill row that skillslug delivery silently drops. Empty is now treated
as not well-formed like any other invalid slug and rejected with 400;
omitting the field is still the only way to leave the slug unchanged.