Skip to content

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

Closed
dimitrovmaksim wants to merge 1 commit intographprotocol:mainfrom
dimitrovmaksim:fix/cli-hex-args-parsed-as-numbers
Closed

fix(cli): preserve hex positional args as strings by re-parsing argv#1187
dimitrovmaksim wants to merge 1 commit intographprotocol:mainfrom
dimitrovmaksim:fix/cli-hex-args-parsed-as-numbers

Conversation

@dimitrovmaksim
Copy link
Copy Markdown
Member

@dimitrovmaksim dimitrovmaksim commented Apr 2, 2026

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.

@github-project-automation github-project-automation bot moved this to 🗃️ Inbox in Indexer Apr 2, 2026
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.
@dimitrovmaksim dimitrovmaksim force-pushed the fix/cli-hex-args-parsed-as-numbers branch from 3ca22c8 to 02f0208 Compare April 2, 2026 19:32
Copy link
Copy Markdown
Contributor

@dwerner dwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@github-project-automation github-project-automation bot moved this from 🗃️ Inbox to ✅ Approved in Indexer Apr 2, 2026
@dimitrovmaksim
Copy link
Copy Markdown
Member Author

closing in favor of #1188

@github-project-automation github-project-automation bot moved this from ✅ Approved to ❌ Closed 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: ❌ Closed

Development

Successfully merging this pull request may close these issues.

2 participants