Fix Formulir and Berkasna API response handling#37
Merged
Conversation
…se shape
Two unrelated bugs in the read-only sawala CLI commands and MCP tools
both reaching for backend resources the dashboard already serves, but
failing because the request shape did not match what the backend returns.
Formulir: URLs constructed `/forms/?limit=100` with a trailing slash
between the resource segment and the query string. Hono's default
router treats `/forms` and `/forms/` as distinct paths, and the
backend route is `path: '/'` mounted at `/projects/:projId/forms`
which only matches `/projects/:projId/forms` (no trailing slash) — the
dashboard's call uses that shape. Verified locally with a small
@hono/zod-openapi repro that `/projects/p1/forms/?limit=100` returns
404 while `/projects/p1/forms?limit=100` returns 200. Drop the slash
on all five call sites: `formulirListFormsTool`, plus the slug→id
fallback shared by `formulirGetFormTool`, `formulirListSubmissionsTool`,
and `formulirGetSubmissionTool`, and the matching `sawala formulir`
commands.
Berkasna: the list-assets tool declared a response shape of
`{items, hasMore, nextCursor}` but the worker actually returns
`{data, meta: {cursor, hasMore}}` (per services/berkasna/src/services/
assets.ts and confirmed by the dashboard's `PaginatedAssetsResponse`
type). The asset row likewise exposes `filename` and `url`, not
`originalName` and `publicUrl`. The tool's `result.items.map(...)`
threw at runtime as soon as the call succeeded against the real
backend. Update both `berkasnaListAssetsTool` and `berkasnaGetAssetTool`
to read the actual fields, and rename the typed interfaces and the
human-readable descriptions accordingly so the LLM is told to look at
`url`, not `publicUrl`. The `sawala berkasna asset list/get` commands
get the same treatment.
Tests updated to mock the real backend response shape so they would
have caught either regression.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix API response handling for Formulir and Berkasna endpoints in both the CLI and MCP tools to match the actual backend response shapes.
Key Changes
Formulir fixes:
/forms/?limit=100→/forms?limit=100)formulir.tslist/get, and MCP tools for forms/submissions list/get operations/formsand/forms/as distinct routes; backend uses the non-slash versionBerkasna fixes:
{items, hasMore, nextCursor}to{data, meta: {cursor, hasMore}}originalName→filenamepublicUrl→urlsha256→fileHashprojectIdfield'ready'to'completed'publicUrltourlImplementation Details
https://claude.ai/code/session_017t8AXAuBBRQz43YWt6W5ei