feat(locations): finalize external_key auto-mint — LOC-NNN + frontend (TRA-551)#418
Merged
Merged
Conversation
…rontend (TRA-551)
Backend auto-mint plumbing (storage + model + handler + spec) shipped
preemptively under TRA-665 / BB26 D3. This finishes the loop:
* Format: LOC-%04d → LOC-%03d, per 2026-05-27 triage. Locations are
typically named-and-known; auto-minted keys are the exception, so the
width is intentionally narrower than ASSET-%04d. Sequence grows
naturally past 999 (LOC-1000+) since the pattern-match query is
digit-count-agnostic.
* Integration test: tightened regex to ^LOC-\d{3,}$ and added an
explicit first-key assertion (LOC-001 in a fresh org).
* Frontend LocationForm: dropped the required asterisk, allowed blank
submit through validateIdentifier, omits external_key from the POST
body when blank on create — mirrors AssetForm.tsx (TRA-650 / BB23 F3).
* Helper text updated: "Optional. Leave blank to auto-assign (e.g.,
LOC-001)."
* Comments + swagger annotations + regenerated OpenAPI spec describe
the new LOC-NNN format.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🚀 Preview Deployment Update ✅ This PR has been successfully merged into the preview branch. The preview environment will update shortly at: https://app.preview.trakrf.id |
5 tasks
Spectral rule trakrf-no-internal-references-in-descriptions (BB28 S1) caught the ticket ref I left in CreateLocationRequest.ExternalKey's doc comment — it flows through swaggo into the public OpenAPI description, where internal references aren't allowed. Stripped "— TRA-551" from the model comment; regen'd spec. The ticket attribution stays in storage/locations.go and the integration test where it doesn't reach the public surface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🚀 Preview Deployment Update ✅ This PR has been successfully merged into the preview branch. The preview environment will update shortly at: https://app.preview.trakrf.id |
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
Finishes TRA-551 by aligning the existing location external_key auto-mint plumbing (shipped preemptively under TRA-665 / BB26 D3) with today's triage decision, and wiring the frontend create form so users can actually take the blank-submit path.
LOC-%04d→LOC-%03dper 2026-05-27 triage (LOC-001). Intentionally narrower thanASSET-%04dbecause locations are typically named-and-known artifacts — auto-minted keys are the exception. The pattern-match query inGetNextLocationSequenceis digit-count-agnostic, so the sequence grows naturally past 999 (LOC-1000+).TestPostLocation_OmittedExternalKey_AutoMintsnow asserts^LOC-\d{3,}$and explicitly pinsLOC-001as the first auto-mint in a fresh org.external_keyentirely when blank on create (an explicit empty string still 400s astoo_short, which is correct). MirrorsAssetForm.tsx(TRA-650 / BB23 F3)."Optional. Leave blank to auto-assign (e.g., LOC-001). Otherwise: letters, numbers, hyphens, and underscores only (no spaces)."openapi.public.{json,yaml}describe the newLOC-NNNformat.Why not a fresh
feat:of the backend plumbing too? It was already inmainunder TRA-665. Renaming attribution would just churn blame. The PR title/body documents the TRA-551 closure path.Sequencing per the triage note: TRA-844 (SPA report-names fix) has already shipped (merge commit 332e97b), so the readability concern is resolved.
Test plan
go test -tags=integration ./internal/handlers/locations/...— passgo test -tags=integration ./internal/storage/...— passpnpm exec vitest run src/components/locations/ src/lib/location/— 167/167 passjust backend lint— cleanpnpm typecheck— cleanpnpm lint— 0 errors (376 pre-existing warnings)LOC-NNNshows in list/detailcurl -X POST .../api/v1/locations -d '{"name":"smoke"}'→ returns 201 withexternal_keymatching^LOC-\d{3,}$🤖 Generated with Claude Code