Skip to content

fix: surface detailed simulation errors including InsufficientFundsFo…#951

Open
Sushil-19 wants to merge 4 commits intosolana-foundation:masterfrom
Sushil-19:fix/surface-insufficient-funds-error
Open

fix: surface detailed simulation errors including InsufficientFundsFo…#951
Sushil-19 wants to merge 4 commits intosolana-foundation:masterfrom
Sushil-19:fix/surface-insufficient-funds-error

Conversation

@Sushil-19
Copy link
Copy Markdown

…rFee

Description

Type of change

  • Bug fix
  • New feature
  • Protocol integration
  • Documentation update
  • Other (please describe):

Screenshots

Testing

Related Issues

Checklist

  • My code follows the project's style guidelines
  • I have added tests that prove my fix/feature works
  • All tests pass locally and in CI
  • I have updated documentation as needed
  • I have run build:info script to update build information
  • CI/CD checks pass
  • I have included screenshots for protocol screens (if applicable)
  • For security-related features, I have included links to related information

Additional Notes

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 16, 2026

@Sushil-19 is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 16, 2026

Greptile Summary

This PR replaces the hardcoded setError('TransactionError') with a parseSimulationError helper that inspects the structured error value and log lines to return a meaningful message (e.g. "Insufficient funds for transaction fee"). It also removes a now-redundant setError call in the zero-logs branch whose result was always overwritten by the generic setter below it.

Confidence Score: 5/5

Safe to merge — the change is a clear improvement over the previous hardcoded generic error string, with only minor style-level findings.

All findings are P2 (stale comment, loose any type, log-scan ordering preference). No logic bugs or runtime regressions were found; the removal of the redundant setError call in the zero-logs branch is actually a latent bug fix.

No files require special attention.

Important Files Changed

Filename Overview
app/features/instruction-simulation/model/use-simulation.ts Adds parseSimulationError to surface structured Solana simulation errors (especially InsufficientFundsForFee) instead of always showing a generic "TransactionError" string; also removes the now-redundant setError call in the zero-logs branch.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[simulateTransaction response] --> B{resp.value.err?}
    B -- no --> C[No error set]
    B -- yes --> D[parseSimulationError]
    D --> E{logs include InsufficientFundsForFee?}
    E -- yes --> F[Return human-readable fee message]
    E -- no --> G{typeof err === string?}
    G -- yes --> H{err includes InsufficientFundsForFee?}
    H -- yes --> F
    H -- no --> I[Return err string as-is]
    G -- no --> J{typeof err === object?}
    J -- yes --> K{InsufficientFundsForFee in err?}
    K -- yes --> F
    K -- no --> L[Return JSON.stringify err]
    J -- no --> M[Return Transaction failed]
    F --> N[setError with message]
    I --> N
    L --> N
    M --> N
Loading

Reviews (1): Last reviewed commit: "fix: surface detailed simulation errors ..." | Re-trigger Greptile

Comment thread app/features/instruction-simulation/model/use-simulation.ts
Comment thread app/features/instruction-simulation/model/use-simulation.ts Outdated
Comment on lines +33 to +35
if (logs?.some(l => l.includes('InsufficientFundsForFee'))) {
return 'Insufficient funds for transaction fee';
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Logs scanned before the error object is inspected

The function checks whether any log line contains 'InsufficientFundsForFee' before examining the structured err value. A log line from an inner CPI call or a diagnostic message that merely mentions that string would trigger the wrong human-readable label even if the real top-level error is something different (e.g. InstructionError). Inspecting the structured err first is more reliable; fall back to log-scanning only when the error object doesn't match.

Sushil-19 and others added 3 commits April 17, 2026 00:44
added recommended comment

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
added the recommended preferred types instead of using any

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@Sushil-19
Copy link
Copy Markdown
Author

Sushil-19 commented Apr 16, 2026

Updated, prioritizing structured error over logs.
Fixes #586

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.

1 participant