fix(mcp): surface the database reason and code behind LINK_TX_DB_ERROR to the approver (#1807)
* fix(mcp): surface the database reason and code behind LINK_TX_DB_ERROR to the approver gnubok_link_transaction_to_journal_entry failed reproducibly for a customer on certain incoming payments with a bare LINK_TX_DB_ERROR: the service put the Postgres message in details.reason, but the code had no structured entry and the commit dispatcher dropped executor data on failure, so neither the MCP approve result nor result_data said why. LINK_TX_DB_ERROR now has a structured entry; the executor appends the DB reason to the message and sets errorCode; the dispatcher persists and returns executor failure details (result_data.details, CommitResult.data, .code); gnubok_approve_pending_operation exposes error_code. The next failing call tells us which constraint or trigger fired. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(mcp): keep tools/list under the context budget (drop approve schema descriptions) The two output-schema descriptions added for data/error_code pushed the projected tools/list payload 7 tokens over the ceiling guarded by payload-size.bench.test.ts. The fields stay; the prose goes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(pending-ops): log loudly when the terminal rejected write fails Review finding: the rejection branch wrote pending_operations without checking the result, so a failed write left the row in 'committing' with the executor error, code and details lost silently. Mirror the finalize branch: inspect the write result and log with the ids plus the failure we could not persist; the daily recovery sweep still resolves the row. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
1f6dd778e5
commit
9622382579
@@ -678,6 +678,16 @@ const LINK_TX_JE: Record<string, StructuredErrorEntry> = {
|
||||
message_en:
|
||||
'Transaction and invoice currency must match to link to an existing voucher. Use the match-invoice flow for cross-currency settlement.',
|
||||
},
|
||||
// Raw database failure on the transaction or invoice UPDATE. The service
|
||||
// puts the Postgres message in details.reason; callers append it so the
|
||||
// constraint or trigger that fired is visible to the agent instead of a
|
||||
// bare code (a customer hit this reproducibly on certain positive amounts
|
||||
// and could not tell us why).
|
||||
LINK_TX_DB_ERROR: {
|
||||
httpStatus: 500,
|
||||
message_sv: 'Kopplingen kunde inte sparas i databasen.',
|
||||
message_en: 'Linking the transaction to the journal entry failed at the database.',
|
||||
},
|
||||
}
|
||||
|
||||
const MATCH_SI: Record<string, StructuredErrorEntry> = {
|
||||
|
||||
Reference in New Issue
Block a user