<!-- XE-1857 · `asBigInt` lets plain `Error`s escape the typed client accessors on malformed numeric fields · testnet -->
*Markdown view of <https://bounty.xe.network/XE-1857>. The page is the record; this is the same page for reading.*

XE-1857 · Bounty

# \`asBigInt\` lets plain \`Error\`s escape the typed client accessors on malformed numeric fields

Triaging
claimed Minor
web
filed 2026-11-09 08:09 UTC
by Darkarmy921

Verdict
:   published when the fix ships

Tier
:   published when the fix ships

Claimed
:   Minor

Area
:   SDK / docs / web

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-14 22:57 UTC

Told
:   2026-11-10 14:00 UTC

### Patches

None linked.

### History

- [211821](https://bounty.xe.network/log/211821) 2026-11-14 22:57 UTC proposal.adopted
- [211820](https://bounty.xe.network/log/211820) 2026-11-14 22:57 UTC ticket.award
- [84110](https://bounty.xe.network/log/84110) 2026-11-10 14:00 UTC proposal.adopted
- [84109](https://bounty.xe.network/log/84109) 2026-11-10 14:00 UTC reply.sent
- [83972](https://bounty.xe.network/log/83972) 2026-11-10 14:00 UTC proposal.adopted
- [83971](https://bounty.xe.network/log/83971) 2026-11-10 14:00 UTC ticket.status new → triaging
- [83647](https://bounty.xe.network/log/83647) 2026-11-10 14:00 UTC proposal.adopted
- [83646](https://bounty.xe.network/log/83646) 2026-11-10 14:00 UTC proposal.adopted
- [83645](https://bounty.xe.network/log/83645) 2026-11-10 14:00 UTC ticket.facts
- [83644](https://bounty.xe.network/log/83644) 2026-11-10 14:00 UTC proposal.adopted
- [83643](https://bounty.xe.network/log/83643) 2026-11-10 14:00 UTC ticket.facts
- [83642](https://bounty.xe.network/log/83642) 2026-11-10 14:00 UTC proposal.adopted

[Full history](https://bounty.xe.network/log?ref=XE-1857) · [JSON](https://bounty.xe.network/v1/tickets/XE-1857) · [markdown](https://bounty.xe.network/XE-1857.md)

### Report

## Title

`asBigInt` lets plain `Error`s escape the typed client accessors on malformed numeric fields

## Summary

Every typed client accessor funnels node-supplied numerics through
`asBigInt` (`src/json.ts`), which throws a bare `Error` ("`field: expected an integer, got …`") on a non-integer value. That plain
`Error` propagates unchanged out of `balances()`, `pending()`,
`certificate()`, `lease()`, and — by code-reading, same helper —
`toProvider`, `toEpoch`, `timekeepers()`, `requestAttestation()` and
`latestEpoch()`'s index read. The SDK's error taxonomy (`XeError` →
`XeApiError` / `XeTransportError` / `XeUsageError`) is the contract
callers code against: `isRetryable()` only recognises `XeApiError`
and `XeTransportError`, `Xe.rentLease` and `holdLease`'s retry logic
branch on `instanceof XeApiError`, and `XeClient.request()` only
retries `isRetryable` errors. A malformed numeric field therefore
produces an error that is invisible to every one of those handlers —
it is neither retryable-classified nor usage-classified, it is just a
raw `Error` with no status, no retryable flag, and no body.

## Impact

- **Typed-error contract broken on the malformed-response path.**
  A node (or a proxy/malicious node — the SDK already has to assume
  node responses may be hostile, cf. SDK-2) returning e.g.
  `{"balances":{"XE":"abc"}}` makes `balances()` throw a plain
  `Error`; the same for a non-integer `pending.Amount`, certificate
  `price_multiplier_milli`, or lease `cost`. Callers that catch
  `XeError` — as the SDK's own `rentLease`/`waitForLease`/
  `holdLease` code does — miss it, and retry logic cannot classify
  it.
- **Scope limit (stated plainly).** The failure is fail-closed (the
  call throws; nothing is signed on a garbage value) and the trigger
  needs a malformed response. No funds move and no wrong value is
  used.

## Severity reasoning

- **Minor, not Low:** the defect is in the error taxonomy itself —
  the same class as DAO-12 (`_unwrap` raises raw `JSONDecodeError`)
  and DAO-13 (`Signer.load` lets raw errors escape), both filed as
  Minor — and it affects at least four public accessors plus the
  shared record mappers. But it is fail-closed and needs malformed
  input.

## Root cause

`src/json.ts` `asBigInt` throws a bare `Error` instead of an
`XeError` subclass, and none of its call sites (`toMap` in
`balances()`, `pending()`, `toCertificate`'s `big()`,
`toLeaseRecord`'s `big()`, `toProvider`, `toEpoch`,
`requestAttestation`, `timekeepers`, `latestEpoch`) wraps it.

## Reproduction

Harness `/tmp/sdk-r5/verify.mjs` (section F), mock fetch only. Run
from the built SDK:

```
cd ~/workspace/xe-bounty/sdk
node /tmp/sdk-r5/verify.mjs
```

Observed output:

```
PASS F-balances-plain-error PLAIN:Error
PASS F-pending-plain-error PLAIN:Error
PASS F-certificate-plain-error PLAIN:Error
PASS F-lease-plain-error PLAIN:Error
PASS F-control-good-balances XE=5
```

What the run shows: a non-integer numeric in each of the four
responses makes the accessor throw a plain `Error` (not an
`XeError`); well-formed responses still parse normally.

## Dedup note

Checked against the public ticket list (186 public tickets, max
XE-1799, snapshot 2026-11-09 \~14:19 WIB; title sweep). No title match
for `asBigInt`, plain errors escaping, or malformed numeric fields in
the SDK. Closest reports:

- **XE-1774 (DAO-12)** — `XeClient._unwrap` raises a raw
  `JSONDecodeError` on garbage JSON. Same *class* (raw error escaping
  a typed taxonomy), different codebase (DAO Python client) and
  trigger (unparsable body vs non-integer field).
- **XE-1779 (DAO-13)** — `Signer.load` lets corrupt-keyfile errors
  escape as raw exceptions. Same class, different codebase.
- **XE-0057** — node errors are `{"error": string}` but response
  schemas are the object `Error` shape. About the node's error
  *shape*, not the SDK throwing plain `Error`s on bad numerics.

No known report covers this SDK defect. Private/sealed tickets are
invisible, so a sealed duplicate cannot be ruled out.

## Suggested fix direction

- Make `asBigInt` throw `XeApiError` (status 200, non-retryable,
  body attached) or a dedicated `XeError` subclass, so every
  accessor's malformed-response failure is classifiable by
  `isRetryable` and catchable as `XeError`. Alternatively wrap the
  calls at each accessor — fixing it in `asBigInt` closes the whole
  class at once.

## Payout address

```
052e33e0ed9c43e2bdf07faff9a90d25642b51d53d96f49f5d45b81f6584b3da
```

## References (file:line; sdk @ 605c20a)

| Location | What it shows |
| --- | --- |
| `src/json.ts` (`asBigInt`) | `throw new Error(...)` — bare `Error`, no `XeError` |
| `src/client.ts` (`balances`/`toMap`, `pending`, `toCertificate`/`big`, `toLeaseRecord`/`big`, `toProvider`, `toEpoch`, `requestAttestation`, `timekeepers`, `latestEpoch`) | All call sites that let it escape |
| `src/errors.ts` (`isRetryable`) | Only recognises `XeApiError`/`XeTransportError` — a plain `Error` is unclassifiable |
| `/tmp/sdk-r5/verify.mjs` (section F) | Verification harness (ephemeral, see "Reproduction") |

### Thread

**Joseph Denne**team2026-11-10 14:00 UTCdesk

Thank you for this report. We have read it against the code and it is being handled. The assessment and any award follow the fix. https://bounty.xe.network/XE-1857
