fix(ai-tools): validate MCP billing/contract/catalog payloads with shared Zod schemas; fix void delete_draft return - #3098
Open
ToddHebebrand wants to merge 1 commit into
Open
Conversation
…ared Zod schemas; fix void delete_draft return
Two defects found by live MCP testing:
1. manage_contracts, manage_invoices, and manage_catalog type-cast their
object payloads (input/patch/line/payment/item/override/components)
straight into the service layer with no Zod parse — the HTTP routes
validate these payloads but the MCP path skipped it, so a malformed
payload died as an opaque HTTP 500 DB constraint violation instead of
a structured VALIDATION_ERROR. Payloads now parse with the same shared
schemas the routes use (createContractSchema, manualLineSchema,
createCatalogItemSchema, recordPaymentSchema, etc.), wrapped under
their param name so ZodError paths are self-describing.
2. manage_invoices delete_draft returned JSON.stringify of a void call,
i.e. undefined — the MCP layer rejected the result as a generic tool
failure AFTER the delete had already committed. Now returns {ok:true},
matching manage_contracts/manage_quotes.
Regression tests cover invalid create/update/add_line/payment payloads
(structured VALIDATION_ERROR, service never called) and the delete_draft
return shape.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deploying breeze with
|
| Latest commit: |
4e6c34b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d95b7da1.breeze-9te.pages.dev |
| Branch Preview URL: | https://toddhebebrand-invoice-contra.breeze-9te.pages.dev |
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
Two defects found by live MCP testing of the billing/contract/catalog AI tools:
Unvalidated object payloads on the MCP path.
manage_contracts,manage_invoices, andmanage_catalogtype-cast their object payloads (input/patch/line/payment/item/override/components) straight into the service layer with no Zod parse. The HTTP routes validate these payloads, but the MCP path skipped it entirely, so a malformed payload died as an opaque HTTP 500 DB constraint violation instead of a structuredVALIDATION_ERRORthe model could act on. Payloads now parse with the same shared schemas the routes use (createContractSchema,manualLineSchema,createCatalogItemSchema,recordPaymentSchema, etc.), wrapped under their param name so ZodError paths are self-describing (line.quantity: ...,payment.receivedAt: ...).manage_invoices delete_draftreturned"undefined". It stringified the result of aPromise<void>call, so the MCP layer rejected the result as a generic tool failure after the delete had already committed. Now returns{ok: true}, matching themanage_contracts/manage_quotespattern.Tests
Regression tests cover invalid create/update/add_line/payment payloads (structured
VALIDATION_ERROR, service never called) and thedelete_draftreturn shape:aiToolsBilling.manageInvoices.test.tsaiToolsCatalog.manageCatalog.test.tsaiToolsContracts.manageContracts.test.ts🤖 Generated with Claude Code