Skip to content

fix(indexer): stop scValToNative from silently corrupting plain values - #328

Merged
David1984TK merged 1 commit into
mainfrom
fix/indexer-eventparser-sdk17
Sep 2, 2026
Merged

fix(indexer): stop scValToNative from silently corrupting plain values#328
David1984TK merged 1 commit into
mainfrom
fix/indexer-eventparser-sdk17

Conversation

@David1984TK

Copy link
Copy Markdown
Owner

Descripción

Hotfix de la regresión introducida por #326 (@stellar/stellar-sdk 16.2.0 → 17.0.1).

Causa raíz

@stellar/stellar-sdk 17 cambió el comportamiento de scValToNative: para un valor que no es un xdr.ScVal real, antes lanzaba una excepción; ahora devuelve undefined en silencio.

// confirmado en local con el SDK 17:
scValToNative(10)        // -> undefined (antes: throw)
scValToNative('250000')  // -> undefined (antes: throw)

eventParser.js dependía de que ese throw activara el fallback al valor crudo:

function normalizeArg(arg) {
  try {
    return scValToNative(arg);
  } catch {
    return arg;   // nunca se ejecuta ahora
  }
}

Con el SDK 17, cualquier argumento que ya viniera como valor nativo (no un ScVal real) se convertía en undefined sin que el catch lo notara — de ahí que processor.test.js fallara con { id: NaN, yield_entregado_delta: null } en vez de { id: 10, yield_entregado_delta: "250000" }.

Fix

Si scValToNative devuelve undefined para un argumento que no era undefined, se trata igual que el catch de antes: se conserva el valor crudo.

Verificación

  • npm test — 112/112 tests pasan (antes: 2 fallando en processor.test.js)
  • Reproducido el bug exacto en local contra el SDK 17 antes de escribir el fix

🤖 Generated with Claude Code

https://claude.ai/code/session_01F8ndA3fFsSkp8qw6sqeAva


Generated by Claude Code

@stellar/stellar-sdk 17 (merged via #326) changed scValToNative to
return undefined for a value that isn't a real xdr.ScVal, instead of
throwing. eventParser.js relied on the throw to fall back to the raw
value, so plain already-native args (as used in our tests, and
potentially some event shapes) were getting silently turned into
undefined -> NaN/null downstream.

Fix: treat an unexpected undefined result the same as the old
throw-and-fall-back path. Verified: all 112 indexer tests pass
(previously 2 failing in processor.test.js).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F8ndA3fFsSkp8qw6sqeAva
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bimex-frontend Error Error Sep 2, 2026 7:50pm UTC

@David1984TK
David1984TK merged commit b9be33a into main Sep 2, 2026
6 of 8 checks passed
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