Skip to content

fix: correct cleared and flagColor schema types in CreateTransactionTool#27

Open
jdmadison wants to merge 1 commit into
calebl:mainfrom
jdmadison:fix/create-transaction-schema
Open

fix: correct cleared and flagColor schema types in CreateTransactionTool#27
jdmadison wants to merge 1 commit into
calebl:mainfrom
jdmadison:fix/create-transaction-schema

Conversation

@jdmadison

@jdmadison jdmadison commented Mar 27, 2026

Copy link
Copy Markdown

Problem

ynab_create_transaction was silently ignoring all provided parameters when called, resulting in a no-op with no error surfaced to the caller. The tool would return without creating a transaction, regardless of the arguments passed.

Observed behavior

Any call to ynab_create_transaction with a fully populated payload (accountId, date, amount, payeeId, memo, cleared, approved) produced no transaction and no error. The bug was consistent across all argument combinations.

Expected behavior

The tool should forward all provided parameters to the YNAB API and return a transaction ID on success.

Verification

Tested against a live budget in a real session. After the fix, a batch of 13 concurrent ynab_create_transaction calls all succeeded and returned valid transaction IDs. Parameters including accountId, date, amount, payeeId, memo, cleared, and approved were all correctly forwarded and reflected in the created transactions.

Solution

  • cleared was typed as z.boolean() but the YNAB API expects an enum (cleared, uncleared, reconciled) — this caused the parameter to be silently dropped
  • flagColor was similarly typed as z.string() instead of the proper enum (red, orange, yellow, green, blue, purple, "))
  • Added tests covering valid enum values and rejection of invalid ones

Test plan

  • npm test passes with new enum-specific test cases for both fields
  • Build passes (npm run build)
  • Verified against running container with a real transaction creation

🤖 Generated with Claude Code

The `cleared` field was typed as `z.boolean()` but the YNAB API uses a
string enum ("cleared" | "uncleared" | "reconciled"). When models pass
the enum string (copied from API docs or existing transaction data),
Zod validation fails and the MCP SDK rejects the entire tool call —
manifesting as "drops all parameters".

- Change `cleared` from `z.boolean()` to `z.enum(["cleared", "uncleared", "reconciled"])`
- Add `mapClearedStatus()` helper consistent with UpdateTransactionTool
- Change `flagColor` from `z.string()` to the constrained enum for better validation
- Fix `amount` description to clarify sign convention (negative = outflow)
- Update tests to use string enum values for cleared and flagColor

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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