Skip to content

Use a qualified metadata key for removeTraits - #33

Merged
kubukoz merged 1 commit into
mainfrom
restore-namespaced-metadata-key
Aug 18, 2026
Merged

kubukoz merged 1 commit into
mainfrom
restore-namespaced-metadata-key

Conversation

@kubukoz

@kubukoz kubukoz commented Aug 18, 2026

Copy link
Copy Markdown
Member

Follow-up to #32, restoring the qualified metadata key.

Was it legal Smithy?

Yes. Metadata keys are arbitrary strings — the key member of the @metadata trait is constrained only by @length(min: 1), and the spec's own examples use plain strings like "foo". A # in the key is just a character; the loader attaches no namespace meaning to it. smithytransformations#removeTraits loaded and validated fine all along.

I'd changed it to a bare removeTraits on the basis that the prelude uses shapeClosures. That was a weak inference: one data point, and the prelude is a special case — it owns the global namespace, so it has no collision problem to solve. A third-party library does.

Why qualify it

Metadata merges across every model loaded together, so a bare removeTraits would collide with any other library that picked the same word. The spec is silent on the question, which makes collision-avoidance our call rather than a convention to follow.

The transformer's name — what smithy4sModelTransformers and smithy-build.json reference — stays removeTraits. Only the metadata key is qualified.

sbt clean test passes (30 tests), scalafmt clean.

🤖 Generated with Claude Code

Metadata keys are arbitrary strings, so `smithytransformations#removeTraits`
is legal Smithy — the `#` carries no namespace meaning to the loader, it is
just part of the key.

Qualify it to avoid collisions: metadata is merged across every model loaded
together, so a bare `removeTraits` would clash with any other library that
happened to pick the same word. The prelude's unqualified `shapeClosures` is
not a counter-example — the prelude owns the global namespace and has no
collision to avoid.

The transformer's name, referenced from `smithy4sModelTransformers` and
`smithy-build.json`, stays `removeTraits`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@kubukoz
kubukoz merged commit e9d1bd7 into main Aug 18, 2026
10 checks passed
@kubukoz
kubukoz deleted the restore-namespaced-metadata-key branch August 18, 2026 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant