Skip to content

feat(locations): finalize external_key auto-mint — LOC-NNN + frontend (TRA-551)#418

Merged
mikestankavich merged 2 commits into
mainfrom
fix/tra-551-loc-auto-key-finalize
May 27, 2026
Merged

feat(locations): finalize external_key auto-mint — LOC-NNN + frontend (TRA-551)#418
mikestankavich merged 2 commits into
mainfrom
fix/tra-551-loc-auto-key-finalize

Conversation

@mikestankavich
Copy link
Copy Markdown
Contributor

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.

  • Format: LOC-%04dLOC-%03d per 2026-05-27 triage (LOC-001). Intentionally narrower than ASSET-%04d because locations are typically named-and-known artifacts — auto-minted keys are the exception. The pattern-match query in GetNextLocationSequence is digit-count-agnostic, so the sequence grows naturally past 999 (LOC-1000+).
  • Backend tests: TestPostLocation_OmittedExternalKey_AutoMints now asserts ^LOC-\d{3,}$ and explicitly pins LOC-001 as the first auto-mint in a fresh org.
  • Frontend LocationForm.tsx: dropped the required asterisk; the validator now treats blank as valid; the POST body omits external_key entirely when blank on create (an explicit empty string still 400s as too_short, which is correct). Mirrors AssetForm.tsx (TRA-650 / BB23 F3).
  • Helper text: "Optional. Leave blank to auto-assign (e.g., LOC-001). Otherwise: letters, numbers, hyphens, and underscores only (no spaces)."
  • Spec regen: comments + swaggo annotations + regenerated openapi.public.{json,yaml} describe the new LOC-NNN format.

Why not a fresh feat: of the backend plumbing too? It was already in main under 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/... — pass
  • go test -tags=integration ./internal/storage/... — pass
  • pnpm exec vitest run src/components/locations/ src/lib/location/ — 167/167 pass
  • just backend lint — clean
  • pnpm typecheck — clean
  • pnpm lint — 0 errors (376 pre-existing warnings)
  • Preview deploy smoke: create a location via SPA with the Identifier field blank → confirm assigned LOC-NNN shows in list/detail
  • Preview API smoke: curl -X POST .../api/v1/locations -d '{"name":"smoke"}' → returns 201 with external_key matching ^LOC-\d{3,}$

🤖 Generated with Claude Code

…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>
@github-actions
Copy link
Copy Markdown

🚀 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

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>
@github-actions
Copy link
Copy Markdown

🚀 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

@mikestankavich mikestankavich merged commit 52c6a13 into main May 27, 2026
16 checks passed
@mikestankavich mikestankavich deleted the fix/tra-551-loc-auto-key-finalize branch May 27, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant