This repository was archived by the owner on Sep 1, 2026. It is now read-only.
Restore CKAN standard-variable autocomplete: label_contains + enable_ckan - #9
Merged
Merged
Conversation
…autocomplete
CKAN's dataset form autocompletes MINT standard variables against this API.
That widget broke when the catalog moved from the v1.8.0 FastAPI service to
this one, because two behaviours it relied on were never ported:
- `label` filters with `_eq`, so a partial term matched nothing. The widget
only returned a suggestion once the user typed the entire variable name.
- `enable_ckan` did not exist, so the response was the plain JSON-LD array.
CKAN's `parseCompletions` reads `item.name || item.Name || item.Format`,
none of which our rows carry, so every suggestion collapsed to "".
Add both without changing existing semantics:
- `label_contains=<term>` builds `label: { _ilike: "%term%" }`. `%` and `_`
are escaped so they match literally -- standard variable labels are full of
underscores (`land_surface_wind__speed`), and an unescaped `_` would act as
a single-character wildcard.
- `enable_ckan=true` projects the result into
`{"ResultSet": {"Result": [{"Name": "..."}]}}`.
`label` keeps its exact-match behaviour, so existing callers are unaffected.
Both params are declared on /standardvariables in openapi.yaml -- required,
not just for docs: fastify-openapi-glue validates the querystring and AJV
strips undeclared params before the handler sees them.
Tested at the service level and through the real router, the latter to cover
the AJV stripping and boolean coercion that a direct service call bypasses.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vh9z6U8JosPJnGqPNQf3fk
mosoriob
pushed a commit
to mintproject/mint
that referenced
this pull request
Aug 28, 2026
* chore(model-catalog-api): pin image to the CKAN autocomplete fix Deploys mintproject/model-catalog-api#9, which restores the standard variable autocomplete on the CKAN dataset form. That widget has been returning no suggestions since the catalog moved off the v1.8.0 FastAPI service: `label` filtered with `_eq` so partial terms matched nothing, and `enable_ckan` did not exist so CKAN could not read the response shape. Pin the tag to the commit SHA rather than leaving it on `latest`. This is what most images in values.yaml already do, and it makes the rollout explicit instead of depending on when a pod happens to restart. Chart version bumped so `ct lint` accepts the change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vh9z6U8JosPJnGqPNQf3fk * update Helm documentation --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
The CKAN dataset form autocompletes MINT standard variables against this API. It is broken in production.
The widget was built against the v1.8.0 FastAPI catalog. Two behaviours it depends on were not ported to this service:
labelfilters with_eq. A partial term matches nothing, so a suggestion only appears once the user types the entire variable name.enable_ckandoes not exist. The response is the plain JSON-LD array. CKAN'sparseCompletionsreadsitem.name || item.Name || item.Format; our rows carry none of those, so every suggestion collapses to an empty string.Measured against production before the fix:
Change
Two new query params on the generic list handler, both opt-in.
label_contains=<term>buildslabel: { _ilike: "%term%" }.%and_in the term are escaped so they match literally. This matters: standard variable labels are underscore-heavy (land_surface_wind__speed), and an unescaped_is a single-character wildcard in Postgres, which would make the search quietly wrong rather than obviously broken.enable_ckan=trueprojects the result into{"ResultSet": {"Result": [{"Name": "..."}]}}.labelkeeps its exact-match behaviour, so existing callers are unaffected.Note on the API-design choice
I added a separate param rather than widening
labelto a substring match.labelis live on a deployed API with consumers I cannot enumerate, and there was a test pinning_eq. Turning every resource's exact filter into a substring match seemed like the wrong trade for a fix aimed at one widget. Happy to collapse the two if you would ratherlabeljust do substring.Why the openapi.yaml change is required
Both params are declared on
/standardvariables. This is not only for docs:fastify-openapi-gluevalidates the querystring and AJV strips undeclared params before the handler runs. Implementing them without declaring them would compile, pass every service-level test, and still do nothing in production.Tests
npm test— 134 passed, 38 skipped (was 130).npm run buildclean.15 new tests across two levels:
src/__tests__/integration.test.ts— filter construction, wildcard escaping,label+label_containscombined, response shaping,enable_ckan=falsenot treated as truthy.src/__tests__/standardvariables-ckan-route.test.ts(new) — goes through the real Fastify router with Hasura mocked, covering the AJV stripping and the boolean coercion that a direct service call bypasses.Deploying this
The CKAN side needs a matching one-line change, pointing its autocomplete at
label_contains=?instead oflabel=?(ckanext-dso_scheming/mint_presets.json, in the ckan-docker repo). That change is prepared but not yet merged. The CKAN form stays broken until this is deployed.🤖 Generated with Claude Code
https://claude.ai/code/session_01Vh9z6U8JosPJnGqPNQf3fk