fix(webapp): map custom program errors per failing program#158
Conversation
parseProgramError applied the SPL Token error table to any unmapped custom error code, so e.g. an error 17 from a non-token program would mislabel as 'Token account is frozen'. Attribute the code to the failing program (subscriptions vs SPL Token / Token-2022) before mapping, and fall back to naming the program + code when it can't be attributed. Also complete the standard SPL Token error table (codes 0-19).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Compute Unit Report
Generated: 2026-06-04 |
Greptile SummaryThis PR fixes a bug in
Confidence Score: 4/5Safe to merge; the fix correctly scopes error codes to their emitting program and resolves the reported frozen-account mislabelling. The core attribution logic is correct and well-structured. The one thing to watch is the no-attribution fallback (line 60): when the error message lacks a "Program X failed:" line, SPL token errors in the 0–19 range are no longer resolved to friendly strings, which is a regression from the old behaviour. This is a narrow edge case in practice but worth addressing before shipping. webapp/src/lib/parse-program-error.ts — specifically the final fallback branch and its interaction with the SPL token error table. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[parseProgramError called] --> B{error instanceof Error?}
B -- No --> C[return 'Unknown error']
B -- Yes --> D{hex or decimal error code match?}
D -- No --> E[return error.message]
D -- Yes --> F[extract failedProgram from error message]
F --> G{failedProgram === PROGRAM_ADDRESS?}
G -- Yes --> H[PROGRAM_ERRORS lookup or 'Subscriptions program error N']
G -- No --> I{TOKEN_PROGRAM_IDS.has failedProgram?}
I -- Yes --> J[SPL_TOKEN_ERRORS lookup or 'Token program error N']
I -- No --> K{failedProgram non-empty?}
K -- Yes --> L[return 'Program X error N']
K -- No --> M[PROGRAM_ERRORS lookup or 'Program error N']
Reviews (1): Last reviewed commit: "fix(webapp): map custom errors per faili..." | Re-trigger Greptile |
Summary
parseProgramErrorapplied the SPL Token error table to any unmapped custom error code, regardless of which program threw it. An error 17 from a non-token program would be mislabeled as "Token account is frozen".publicKey) vs SPL Token / Token-2022 (TOKEN_PROGRAM_ADDRESS/TOKEN_2022_PROGRAM_ADDRESS). Unattributable codes fall back to naming the program + code instead of a bare number.AccountFrozen→ "Token account is frozen" (verified against spl-token-interface source).Context
Reported: a recurring-delegation pull on devnet failed with "Program error 17". Confirmed the destination token account was frozen (Token-2022 mint). The old message surfaced the raw code; this makes it readable and correctly scoped to the emitting program.
Test Plan
prettier --checkclean.pnpm --filter webapp exec tsc -bpasses (webapp typechecks clean with the change).webapp/src/lib/parse-program-error.ts.