Repository navigation
fix(domain): seed scope import → 400 for bad kind / slug collision (no opaque 500) - #144
Merged
Merged
Conversation
…lug collision ImportSeedScope now validates kind in the domain and detects a slug that already exists under a different explicit id, returning ErrValidation (HTTP 400) instead of a plain store error / raw UNIQUE constraint failure (500). A seed scope without id reuses the existing scope for its slug (idempotent, matching CreateScope). Patch produced by the Kilo worker (Nemotron 3 Ultra), independently reviewed.
|
Warning Review limit reachedNext included review available in 46 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository: mrchatam/Trace/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
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. Comment |
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.
Problem
ImportSeedScope(internal/domain/seed_import.go) passes seed scopes straight tostore.UpsertScope. When a client sends a bad seed,POST /v1/seed/importanswers with an opaque 500 INTERNAL_ERROR "internal error" (the #104/#114 class):"Feature","", …) is only rejected by the store, with a plainfmt.Errorf, which is not a*domain.ErrValidation.UNIQUE constraint failed: scopes.slug (2067). This also blocks merging seeds from two clones that each created the same slug.Probe on main: both cases are non-
ErrValidation, and the new HTTP tests get500 {"error":{"code":"INTERNAL_ERROR"}}.Fix
ErrValidationnaming the slug.ErrValidation:scope slug "x" already exists with id A while seed has id B.CreateScope.SeedImportSummaryalignment. That file was listed bygofmt -lon main; there is no semantic change.Tests
internal/domain/scope_seed_validation_test.go: bad kind, slug collision, re-import with the same id+slug (exactly oneentity.created), missing slug/title, empty id with an existing slug (no duplicate scope, a singleentity.created).internal/httpapi/seed_scope_validation_test.go: bad kind → 400 VALIDATION_ERROR; slug collision → 400 VALIDATION_ERROR, with both ids in the message.The bad-kind, collision and empty-id domain tests and both HTTP tests fail on main and pass here.
CGO_ENABLED=1 go test ./...passes locally.Patch produced by the Kilo worker (Nemotron 3 Ultra; task
kw-20260926-192614-f795) and independently reviewed and tested by the supervisor. It took 2 revisions: the first fixed compile errors and added the empty-id slug reuse; the second finished after the worker stopped partway through.@coderabbitai review