Skip to content

Fix Formulir and Berkasna API response handling#37

Merged
sutisnamulyana merged 1 commit into
mainfrom
claude/cli-sawala-mcp-400-bug-Sv9uI
May 22, 2026
Merged

Fix Formulir and Berkasna API response handling#37
sutisnamulyana merged 1 commit into
mainfrom
claude/cli-sawala-mcp-400-bug-Sv9uI

Conversation

@sutisnamulyana
Copy link
Copy Markdown
Member

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:

  • Remove trailing slash from forms list endpoint calls (/forms/?limit=100/forms?limit=100)
  • Applied across 5 call sites: formulir.ts list/get, and MCP tools for forms/submissions list/get operations
  • Hono treats /forms and /forms/ as distinct routes; backend uses the non-slash version

Berkasna fixes:

  • Update response shape from {items, hasMore, nextCursor} to {data, meta: {cursor, hasMore}}
  • Rename asset fields to match backend:
    • originalNamefilename
    • publicUrlurl
    • sha256fileHash
    • Remove unused projectId field
  • Update status value from 'ready' to 'completed'
  • Applied to both CLI commands and MCP tools (list and get operations)
  • Update documentation references from publicUrl to url

Implementation Details

  • All changes are in type definitions and API response mapping code
  • No breaking changes to CLI/MCP tool interfaces—only internal response handling
  • Test fixtures updated to reflect actual backend response shapes
  • Changeset added documenting both fixes

https://claude.ai/code/session_017t8AXAuBBRQz43YWt6W5ei

…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.
@sutisnamulyana sutisnamulyana merged commit fc2d396 into main May 22, 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.

2 participants