Skip to content

fix: strict check for offramp_failed status#210

Open
Olexandr88 wants to merge 2 commits intoRequestNetwork:mainfrom
Olexandr88:fix/offramp-failed-clean
Open

fix: strict check for offramp_failed status#210
Olexandr88 wants to merge 2 commits intoRequestNetwork:mainfrom
Olexandr88:fix/offramp-failed-clean

Conversation

@Olexandr88
Copy link
Contributor

@Olexandr88 Olexandr88 commented Feb 6, 2026

Use strict equality for offramp_failed status instead of .includes() to avoid incorrect matching of other offramp states

Summary by CodeRabbit

  • Bug Fixes
    • Improved invoice and payment status detection to more precisely surface offramp states (pending, initiated, failed) and processing status, ensuring more accurate and consistent status displays across the app.

Signed-off-by: Olexandr88 <radole1203@gmail.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 6, 2026

Walkthrough

Refined conditional checks in invoice status utilities: replaced substring matching with exact equality and explicit status lists to classify invoice/payment statuses more precisely.

Changes

Cohort / File(s) Summary
Invoice Status Logic
src/lib/invoice-status.ts
Replaced includes() substring checks with exact equality checks and explicit status sets in getInvoiceTableStatusClass() and getPaymentSectionStatusClass(). Changed status.includes("offramp_failed") to status === "offramp_failed" and `status.includes("offramp")

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: strict check for offramp_failed status' directly and clearly describes the main change: replacing substring checks with strict equality for the offramp_failed status.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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

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.

@greptile-apps
Copy link

greptile-apps bot commented Feb 6, 2026

Greptile Overview

Greptile Summary

This PR improves the robustness of invoice status checking by replacing .includes() substring matching with explicit strict equality checks for offramp status values.

Key Changes:

  • getInvoiceTableStatusClass: Changed from status.includes("offramp_failed") and status.includes("offramp") to explicit checks for status === "offramp_failed", status === "offramp_pending", and status === "offramp_initiated"
  • getPaymentSectionStatusClass: Changed from status.includes("offramp") to explicit checks for the same three offramp status values

Why This Matters:
The previous implementation using .includes() was checking for substring matches, which could lead to unexpected behavior if new status values were added that contain "offramp" as a substring but aren't actual offramp statuses. The new approach is more maintainable and aligns with the defined enum values in src/server/db/schema.ts:50-59.

Minor Issue:
Trailing whitespace was introduced on lines 60, 68, and 95.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward, well-scoped, and improve code quality by replacing substring matching with strict equality checks. The logic correctly maintains the previous behavior while being more explicit and maintainable. All enum values referenced (offramp_failed, offramp_pending, offramp_initiated) are properly defined in the schema. The only minor issue is trailing whitespace.
  • No files require special attention

Important Files Changed

Filename Overview
src/lib/invoice-status.ts Replaced .includes() with strict equality checks for offramp status matching to prevent potential substring matching bugs

Sequence Diagram

sequenceDiagram
    participant Client as Payment Client
    participant Webhook as Webhook Handler
    participant DB as Database
    participant UI as Invoice Status UI
    
    Note over Client,UI: Offramp Payment Flow
    
    Client->>Webhook: payment.processing (subStatus: initiated)
    Webhook->>DB: Update status to offramp_initiated
    DB->>UI: Status: offramp_initiated
    UI->>UI: Display orange badge (offramp in progress)
    
    alt Successful Offramp
        Client->>Webhook: payment.processing (subStatus: pending_internal_assessment)
        Webhook->>DB: Update status to offramp_pending
        DB->>UI: Status: offramp_pending
        UI->>UI: Display orange badge (offramp in progress)
        
        Client->>Webhook: payment.processing (subStatus: fiat_sent)
        Webhook->>DB: Update status to paid
        DB->>UI: Status: paid
        UI->>UI: Display green badge (completed)
    else Failed Offramp
        Client->>Webhook: payment.processing (subStatus: failed)
        Webhook->>DB: Update status to offramp_failed
        DB->>UI: Status: offramp_failed
        UI->>UI: Display red badge (failed)
    end
    
    Note over UI: Status display uses strict equality checks<br/>to avoid substring matching bugs
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

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