Skip to content

fix: fix status code for insufficient fund in new interpreter#1241

Merged
ascandone merged 3 commits intomainfrom
fix/fix-interpreter-error-code
Jan 29, 2026
Merged

fix: fix status code for insufficient fund in new interpreter#1241
ascandone merged 3 commits intomainfrom
fix/fix-interpreter-error-code

Conversation

@ascandone
Copy link
Contributor

@ascandone ascandone commented Jan 28, 2026

@ascandone ascandone requested a review from a team as a code owner January 28, 2026 17:18
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 28, 2026

Walkthrough

Changes refactor error handling for insufficient funds scenarios by embedding numscript.InterpreterError directly in ErrRuntime instead of using a named field, adding a Unwrap() method to support standard error unwrapping semantics, and updating the API to treat numscript.MissingFundsErr identically to ErrInsufficientFunds.

Changes

Cohort / File(s) Summary
Error Handling Refactoring
internal/controller/ledger/errors.go, internal/controller/ledger/numscript_runtime.go, internal/controller/ledger/errors_test.go
Refactored ErrRuntime struct to use anonymous embedded numscript.InterpreterError field (replacing named Inner field), removed explicit Error() method, added Unwrap() method for standard error unwrapping semantics. New test validates that errors.Is() correctly unwraps to underlying MissingFundsErr.
API Insufficient Funds Handling
internal/api/v2/controllers_transactions_create.go
Extended error handling in createTransaction to treat numscript.MissingFundsErr as an insufficient funds error, merging it into the same BadRequest path as ErrInsufficientFunds.
API Test Updates
test/e2e/api_transactions_create_test.go
Simplified "with insufficient funds" test by removing conditional logic that varied expected error code based on data.numscriptRewrite; now always asserts InsufficientFund error code unconditionally.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Errors unwrapped with care divine,
Funds and InterpreterError align,
No Inner names to confuse the way,
Just Unwrap() and errors.Is today!
Tests confirm our logic shines so bright, 🌟

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided by the author. Add a description explaining the rationale for treating numscript.MissingFundsErr as insufficient funds and why the interpreter error structure was refactored.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: fixing status code handling for insufficient funds errors in the new numscript interpreter.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/fix-interpreter-error-code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ascandone ascandone force-pushed the fix/fix-interpreter-error-code branch from 7970f45 to c8203ee Compare January 28, 2026 18:45
@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.49%. Comparing base (7d6d64d) to head (aa79816).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/api/v2/controllers_transactions_create.go 0.00% 0 Missing and 1 partial ⚠️
internal/controller/ledger/errors.go 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1241      +/-   ##
==========================================
- Coverage   74.70%   74.49%   -0.21%     
==========================================
  Files         198      198              
  Lines       10410    10411       +1     
==========================================
- Hits         7777     7756      -21     
- Misses       1508     1513       +5     
- Partials     1125     1142      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ascandone ascandone requested a review from gfyrag January 29, 2026 10:11
@ascandone ascandone added this pull request to the merge queue Jan 29, 2026
Merged via the queue into main with commit 005da48 Jan 29, 2026
7 of 9 checks passed
@ascandone ascandone deleted the fix/fix-interpreter-error-code branch January 29, 2026 12:50
ascandone added a commit that referenced this pull request Jan 30, 2026
* fix: fix status code for insufficient fund in new interpreter

* fix: fix unwrap behaviour

* fix: run precommit
ascandone added a commit that referenced this pull request Jan 30, 2026
…#1244)

* fix: fix status code for insufficient fund in new interpreter

* fix: fix unwrap behaviour

* fix: run precommit
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