chore: remediate code-review findings (6 issues)#29
Merged
anajuliabit merged 2 commits intomainfrom May 7, 2026
Merged
Conversation
Six findings from a TypeScript code review:
HIGH — query/emissions-due: BigInt() on a platform-API value that
arrives as a JS number or scientific-notation string (e.g. 1e18) throws
SyntaxError, surfacing as opaque INTERNAL_ERROR. Replace with a guarded
parseWei() helper that falls back to 0n on anything unparseable.
MEDIUM — query/emissions-due: a single pod's /emissions failure
aborted the whole batch via Promise.all. Per-pod outcomes now carry
either ok:true breakdowns or ok:false structured errors so one bad pod
doesn't black-hole the others.
MEDIUM — state/db: upsertIdempotent.argsFingerprint.slice() crashed
on legacy entries (pre-v0.2 cache files). Render a "(legacy)"
placeholder so the IDEMPOTENCY_ARGS_MISMATCH error stays clean even
when called directly bypassing peekIdempotent's earlier legacy guard.
LOW — replace Object.assign(new Error, {code, hint}) with cliError()
in state/db, state/idempotency, chain/addresses (CLAUDE.md canonical
rule).
LOW — config/load + commands/_base: bare `throw new Error(...)` for
user-facing config errors (bad private key, bad network) surfaced as
INTERNAL_ERROR. Replace with cliError('INVALID_PRIVATE_KEY' /
'INVALID_NETWORK') so agents can match programmatically.
LOW — chain/clients: removed dead withTxLock export. Single-process
CLI doesn't need an in-process tx mutex; nextNonce(blockTag:'pending')
is sufficient. Updated module comment.
Also bumped vitest testTimeout to 20s — `npx tsx` cold-start can
exceed the 5s default in command-error-paths.test.ts, causing flake
unrelated to these changes.
Tests: 99 passing (96 baseline + 3 new pinning legacy-fingerprint
defensiveness, INVALID_NETWORK and INVALID_PRIVATE_KEY codes).
Iter-2 reviewer found that parseWei's regex /^-?\d+$/ accepted negative strings like '-500' as valid bigints. Since claimable emissions are always non-negative, an adversarial or buggy platform API response could drag totalDueREPPO below zero. Tighten the regex to /^\d+$/ and pin the behavior with a unit test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remediates 6 findings from a full-repo TypeScript code review.
Also bumped vitest `testTimeout` to 20s — `npx tsx` cold-start was exceeding the 5s default in `command-error-paths.test.ts`, causing flake unrelated to these changes (verified by running tests on pristine main).
Test plan
🤖 Generated with Claude Code