Skip to content

fix(cli): preserve hex positional args as strings by re-parsing argv#1188

Merged
dwerner merged 1 commit intomainfrom
fix-cli-hex-args-parsed-as-numbers
Apr 2, 2026
Merged

fix(cli): preserve hex positional args as strings by re-parsing argv#1188
dwerner merged 1 commit intomainfrom
fix-cli-hex-args-parsed-as-numbers

Conversation

@dimitrovmaksim
Copy link
Copy Markdown
Member

@dimitrovmaksim dimitrovmaksim commented Apr 2, 2026

Resolves #1186

Problem

gluegun uses yargs-parser internally to parse CLI arguments. yargs-parser converts hex strings to numbers before the command handlers see them.

graph-indexer indexer allocations close 0xallocationId "0x0000000000000000000000000000000000000000000000000000000000000010" --network mainnet
[ '0xallocationId', 16 ]

This caused two bugs in v0.25.6/7:

  1. Zero POI normalization silently skipped — normalizePOIParams used strict equality (=== '0'), but gluegun delivered integer 0. Since 0 === '0' is false, the normalization was skipped and the raw integer was forwarded to the GraphQL mutation which expects a String.
  2. Non-zero hex POIs corrupted — any hex POI value passed as a CLI arg would be converted to an imprecise float, making it impossible to recover the original 32-byte hex string downstream.

Note: v0.25.4 used loose equality (== '0') which accidentally caught the integer case, but the refactor to normalizePOIParams in v0.25.6 switched to ===, reintroducing the bug.

What this PR does:

Adds getRawPositionalArgs() in command-helpers.ts which re-parses process.argv with parse-numbers: false, bypassing yargs-parser's number coercion.

gluegun uses yargs-parser internally which converts hex strings (e.g. 0x0,
0x...0010) to numbers before commands see them, making the conversion
irreversible. This caused normalizePOIParams to silently skip zero-POI
normalization (0 === '0' is false) and corrupted non-zero hex POI values.

Add getRawPositionalArgs() which re-parses process.argv with parse-numbers
disabled and slices off the subcommand prefix to recover the original strings.
Apply it across all 10 commands that use parameters.array.
@github-project-automation github-project-automation bot moved this from 🗃️ Inbox to ✅ Approved in Indexer Apr 2, 2026
@dwerner dwerner merged commit 22ff4cb into main Apr 2, 2026
9 of 19 checks passed
@dwerner dwerner deleted the fix-cli-hex-args-parsed-as-numbers branch April 2, 2026 20:01
@github-project-automation github-project-automation bot moved this from ✅ Approved to 🚗 Merged in Indexer Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🚗 Merged

Development

Successfully merging this pull request may close these issues.

[BUG] v0.25.6 regression: graph indexer actions queue unallocate fails with GraphQL string coercion error

2 participants