Skip to content

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

Merged
ascandone merged 1 commit intorelease/v2.3from
hotfix/v2.3/fix-interpreter-status-code
Jan 30, 2026
Merged

fix: fix status code for insufficient fund in new interpreter (#1241)#1244
ascandone merged 1 commit intorelease/v2.3from
hotfix/v2.3/fix-interpreter-status-code

Conversation

@ascandone
Copy link
Contributor

@ascandone ascandone commented Jan 30, 2026

backport #1241

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

* fix: fix unwrap behaviour

* fix: run precommit
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

Walkthrough

This pull request refactors error handling for insufficient funds scenarios in transaction creation. It changes the ErrRuntime error type from using an explicit Inner field to an embedded InterpreterError with an Unwrap() method, updates the transaction API to recognize numscript.MissingFundsErr as insufficient funds, and simplifies related test assertions.

Changes

Cohort / File(s) Summary
Error Type Refactoring
internal/controller/ledger/errors.go, internal/controller/ledger/numscript_runtime.go
Changed ErrRuntime struct field from named Inner to anonymous embedded numscript.InterpreterError. Removed explicit Error() method and added Unwrap() method for proper error chain unwrapping. Updated field initialization in numscript_runtime.go to use new embedded field.
API Error Handling
internal/api/v2/controllers_transactions_create.go
Added numscript import and broadened insufficient funds error handling to treat numscript.MissingFundsErr as a BadRequest with ErrInsufficientFund.
Test Coverage
internal/controller/ledger/errors_test.go, test/e2e/api_transactions_create_test.go
Added new test verifying ErrRuntime properly unwraps to MissingFundsErr. Simplified e2e test by removing conditional error handling logic based on numscriptRewrite flag.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A refactoring dance, so clean and bright,
Errors now unwrap with Unwrap's might!
Missing funds caught in the right way,
Embedded and tested—hop, hooray! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
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.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly summarizes the main change: fixing the status code for insufficient fund errors in the new interpreter.
Description check ✅ Passed The description relates to the changeset by indicating it is a backport of a PR that fixes status codes for insufficient funds in the new 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 hotfix/v2.3/fix-interpreter-status-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.

@codecov
Copy link

codecov bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.78%. Comparing base (8492f23) to head (8e13adf).
⚠️ Report is 1 commits behind head on release/v2.3.

Additional details and impacted files
@@               Coverage Diff                @@
##           release/v2.3    #1244      +/-   ##
================================================
+ Coverage         81.69%   81.78%   +0.08%     
================================================
  Files               187      187              
  Lines              9059     9059              
================================================
+ Hits               7401     7409       +8     
+ Misses             1220     1215       -5     
+ Partials            438      435       -3     

☔ 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 marked this pull request as ready for review January 30, 2026 15:59
@ascandone ascandone requested a review from a team as a code owner January 30, 2026 15:59
@ascandone ascandone requested a review from gfyrag January 30, 2026 15:59
@ascandone ascandone merged commit b058690 into release/v2.3 Jan 30, 2026
8 of 9 checks passed
@ascandone ascandone deleted the hotfix/v2.3/fix-interpreter-status-code branch January 30, 2026 16:06
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