Skip to content

Accept spaces in ?terms= and match space/_/- insensitively - #50

Merged
scottypate merged 1 commit into
mainfrom
fix/terms-accept-spaces
Oct 15, 2026
Merged

scottypate merged 1 commit into
mainfrom
fix/terms-accept-spaces

Conversation

@scottypate

Copy link
Copy Markdown
Contributor

GET /context?terms=white%20paper was a 400 (ADR 0017 §3 grammar). A caller relaying a person's own words asks for white paper, not white_paper; rewriting the request client-side would search for a token the person never said.

  • serve: terms tokens may contain interior spaces and are trimmed; other out-of-grammar characters still 400.
  • context::term_key: lookup key (lowercased, runs of whitespace/_/- folded to _) used by resolve_terms, narrow_terms, resolve_semantic_matches. white paper, White-Paper, white_paper all hit a white_paper term/alias/Ossie synonym.
  • is_addressable_token admits interior spaces so spaced Ossie synonyms join the index; datamk sync warning reuses it.
  • is_model_token keeps ?model='s stricter grammar for the OpenAPI enum.
  • Definition uniqueness checked on term_key.
  • ADR 0017 §3 / ADR 0018 §7 amended.

Tests: 917 + 33 pass, clippy and fmt clean.

🤖 Generated with Claude Code

A caller relaying a person's own words asks for `white paper`, not
`white_paper`; rewriting the request client-side would search for a
token the person never said. The /context door previously 400'd any
`terms` token with a space (ADR 0017 §3 grammar).

- serve: `terms` tokens may contain interior spaces and are trimmed;
  other out-of-grammar characters still 400.
- context::term_key: the lookup key — lowercased, runs of whitespace/
  `_`/`-` folded to one `_` — used by resolve_terms, narrow_terms and
  resolve_semantic_matches, so `white paper`, `White-Paper` and
  `white_paper` all hit a `white_paper` term, alias or Ossie synonym.
- is_addressable_token admits interior spaces, so spaced Ossie names
  and synonyms join the index; `datamk sync`'s warning reuses it.
- is_model_token keeps `?model=`'s stricter no-space grammar for the
  OpenAPI enum, so the enum never offers a value that 400s.
- definitions uniqueness is checked on term_key, so two names that
  would be unreachable from each other can't both be declared.
- ADR 0017 §3 / ADR 0018 §7 amended.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@scottypate
scottypate merged commit 414a18c into main Oct 15, 2026
2 checks passed
@scottypate
scottypate deleted the fix/terms-accept-spaces branch October 15, 2026 08:13
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