Skip to content

fix(cli): serialize the withdrawal config bigints in cartesi status --json - #587

Open
jplgarcia wants to merge 1 commit into
prerelease/v2-alphafrom
fix/status-json-bigint
Open

jplgarcia wants to merge 1 commit into
prerelease/v2-alphafrom
fix/status-json-bigint

Conversation

@jplgarcia

Copy link
Copy Markdown
Member

Problem

cartesi status --json exits 1 with Do not know how to serialize a BigInt as soon as a deployed application has a withdrawal config (found on 2.0.0-alpha.42; the code is unchanged in 2.0.0-alpha.43). getDeployments parses withdrawal_config into NodeWithdrawalConfig, whose drive fields (accountsDriveStartIndex, log2LeavesPerAccount, log2MaxNumOfAccounts) are bigints, and the command passed the deployments straight to JSON.stringify. Plain cartesi status (the table) is not affected.

Fix

  • Move the JSON formatting into formatStatusJson, which writes bigints as decimal strings with the same replacer formatValue (config/errors.ts) already uses.
  • Deployments without a withdrawal config are written exactly as before.
  • Add a patch changeset.

Tests

  • New tests/unit/commands/status.test.ts: one case without a withdrawal config, one with it. The second case failed before the fix with JSON.stringify cannot serialize BigInt.
  • bun test tests/unit: 558 pass. biome check and tsc are clean.
  • Not run end to end against a live cartesi run environment.

The docs removed their mention of cartesi status --json in cartesi/docs#359 because of this bug; it can come back once this is released.

🤖 Generated with Claude Code

…-json

`cartesi status --json` failed with "Do not know how to serialize a
BigInt" as soon as a deployed application had a withdrawal config, whose
drive fields are bigints. Write them as decimal strings, as formatValue
already does for TOML values.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@changeset-bot

changeset-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9064850

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cartesi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 84.6% (🎯 0%) 14115 / 16685
🔵 Statements 84.6% 14115 / 16685
🔵 Functions 79.17% 380 / 480
🔵 Branches 0% 0 / 0
📁 File Coverage (20 files)
File Lines Statements Functions Branches Uncovered Lines
apps/cli/src/api/build.ts 🔴 6.74% 🔴 6.74% 🔴 0% 🔴 0% 90-146, 151-157, 172-273
apps/cli/src/api/connection.ts 🟢 88.89% 🟢 88.89% 🟢 100% 🔴 0% 70-72
apps/cli/src/api/deposit/common.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/api/deposit/erc1155.ts 🔴 4.21% 🔴 4.21% 🔴 0% 🔴 0% 80-159, 170-263, 272-302
apps/cli/src/api/deposit/erc20.ts 🔴 8% 🔴 8% 🔴 0% 🔴 0% 32-45, 77-154
apps/cli/src/api/deposit/erc721.ts 🔴 6.3% 🔴 6.3% 🔴 0% 🔴 0% 41-50, 79-187
apps/cli/src/api/deposit/ether.ts 🔴 15.56% 🔴 15.56% 🔴 0% 🔴 0% 29-66
apps/cli/src/api/deposit/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/api/deposit/progress.ts 🟡 66.67% 🟡 66.67% 🔴 0% 🔴 0% 14, 18
apps/cli/src/api/doctor.ts 🔴 34.97% 🔴 34.97% 🔴 30% 🔴 0% 57-74, 79-91, 95-106, 110-1...
apps/cli/src/api/logs.ts 🔴 38.82% 🔴 38.82% 🟡 60% 🔴 0% 12-23, 136-175
apps/cli/src/api/run.ts 🔴 4.98% 🔴 4.98% 🔴 0% 🔴 0% 222-244, 248-261, 268-286, ...
apps/cli/src/api/send.ts 🟡 71.96% 🟡 71.96% 🟡 75% 🔴 0% 46-47, 74-78, 95, 104, 156-176
apps/cli/src/api/status.ts 🔴 15.79% 🔴 15.79% 🔴 0% 🔴 0% 31-46
apps/cli/src/api/types.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/base.ts 🔴 42.11% 🔴 42.11% 🟡 70.59% 🔴 0% 62, 101-174, 200-204, 208-2...
apps/cli/src/builder/directory.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/docker.ts 🟢 87.5% 🟢 87.5% 🟢 81.82% 🔴 0% 89-91, 93, 126-128, 186-195
apps/cli/src/builder/empty.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo
Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant