Skip to content

backend(sorobanService): readCreditScore() has no fallback when contract simulation fails, crashes loan request flow #660

@ogazboiz

Description

@ogazboiz

Join our community: https://t.me/+DOylgFv1jyJlNzM0

Description

readCreditScore() in backend/src/services/sorobanService.ts calls the RemittanceNFT contract via simulateTransaction() to read a borrower's credit score. If the simulation fails (RPC downtime, contract not found, new borrower with no NFT yet), the function throws and the entire loan request endpoint returns a 500 error.

New borrowers who have not yet received an NFT would always get a 500 error when trying to request a loan, because the NFT contract returns an error for unknown addresses.

Expected Behavior

For a new borrower with no NFT, return a default score (e.g., 500) and let the loan eligibility check handle the rest. For RPC failures, retry or return a degraded response rather than crashing.

try {
  return await simulateCreditScore(borrower);
} catch (err) {
  if (isNotFoundError(err)) return DEFAULT_CREDIT_SCORE; // new borrower
  throw err; // real RPC error, propagate
}

Impact

Medium. New users to the protocol cannot request their first loan because the credit score read throws. The error message is also confusing ("internal error" rather than "no credit history yet").

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions