Skip to content

fix(sawala): resolve Kontena schemas by slug in entry create/update/delete - #101

Merged
sutisnamulyana merged 1 commit into
mainfrom
fix/kontena-entry-slug-lookup
Aug 4, 2026
Merged

fix(sawala): resolve Kontena schemas by slug in entry create/update/delete#101
sutisnamulyana merged 1 commit into
mainfrom
fix/kontena-entry-slug-lookup

Conversation

@sutisnamulyana

Copy link
Copy Markdown
Member

The bug

sawala kontena entry create|update|delete <schemaSlug> failed with NOT_FOUND (…/schemas/<slug>) for every schema — the commands were unusable. The sawala_kontena_{create,update,delete}_entry MCP tools failed identically.

Each verb looks the schema up first, to decide whether to write to the single or the collection content route:

  • the schema-get route resolves ULIDs only
  • the content route it feeds resolves the schema by slug (eq(schemas.slug, schemaSlug))

So the identifier that makes the write succeed is exactly the one that 404s on the lookup, and there is no value that satisfies both. A ULID passes the pre-flight and fails the write; a slug fails the pre-flight.

Found while seeding content for the sawala.cloud marketing blog, where every entry create failed against a freshly created schema.

The fix

fetchSchemaType now falls back to listing the project's schemas and matching by slug on a 404 — the same fallback sawala kontena schema get already had. The list rows already carry type, so this costs one extra request, not two.

The three MCP entry tools had three copies of the same pre-flight; they now share one resolveSchemaType helper (packages/sawala-mcp/src/lib/kontena-schema.ts), so the bug can't come back in only two of them.

A genuinely absent schema now reports Schema 'x' not found. Available slugs: posts, pages. instead of a bare NOT_FOUND.

Note on the existing tests

The pre-existing tests stubbed schema-get as succeeding on a slug path, which encoded the very assumption that was wrong — which is how this shipped. The new cases stub the 404 the real server returns.

Verification

  • Five new cases: the fallback, single-vs-collection routing through it, and the not-found message. All five fail before this change and pass after (verified by stashing the source and re-running).
  • npm run typecheck && npm run test && npm run check:skills — clean; 545 tests pass.
  • Confirmed against production: with a locally built CLI, three entries were created in a real Kontena project that previously rejected every attempt.

Also included

package-lock.json workspace versions had drifted from the package.json versions (@sawala/cli recorded as 0.9.0 vs the actual 0.14.1). Any npm install corrects this; it is unrelated to the fix but was picked up in the same install.

Changeset: patch bump for @sawala/cli and @sawala/mcp.

🤖 Generated with Claude Code

…elete

`sawala kontena entry create|update|delete <schemaSlug>` failed with
`NOT_FOUND (…/schemas/<slug>)` for every schema, as did the matching
create/update/delete entry MCP tools.

Each verb first looks the schema up to decide whether to write to the
`single` or the `collection` content route. That lookup resolves ULIDs
only, while the content route it feeds resolves the schema by *slug* —
so the identifier that makes the write succeed is exactly the one that
makes the lookup 404, and no value satisfies both.

`fetchSchemaType` now falls back to listing the project's schemas and
matching by slug, mirroring `schema get`. The list rows already carry
`type`, so the fallback costs one request rather than two. The three
MCP tools share a new `resolveSchemaType` helper instead of repeating
the pre-flight three times. A genuinely missing schema now reports
`Schema 'x' not found. Available slugs: …` rather than a bare NOT_FOUND.

Also syncs package-lock.json, whose workspace versions had drifted from
the package.json versions (@sawala/cli recorded as 0.9.0 vs 0.14.1).

Tests: three CLI cases and two MCP cases covering the fallback, the
single-vs-collection routing through it, and the not-found message. All
five fail before this change and pass after.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sutisnamulyana
sutisnamulyana merged commit 917500d into main Aug 4, 2026
1 check passed
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