Skip to content

Use string in extensions Block Height to be consistent#3187

Open
MitchTurner wants to merge 9 commits intomasterfrom
bugfix/change-extensions-height-type
Open

Use string in extensions Block Height to be consistent#3187
MitchTurner wants to merge 9 commits intomasterfrom
bugfix/change-extensions-height-type

Conversation

@MitchTurner
Copy link
Copy Markdown
Member

Linked Issues/PRs

#3177

Description

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

@MitchTurner MitchTurner self-assigned this Jan 23, 2026
@MitchTurner MitchTurner marked this pull request as ready for review January 26, 2026 16:22
@MitchTurner MitchTurner requested review from a team, Dentosal, rymnc and xgreenx as code owners January 26, 2026 16:22
@cursor
Copy link
Copy Markdown

cursor bot commented Jan 26, 2026

PR Summary

Medium Risk
Changes the GraphQL response extensions type for current_fuel_block_height from numeric to string, which can break downstream clients relying on the old JSON type. Client deserialization is updated to tolerate missing values and parse the string back into BlockHeight.

Overview
GraphQL response extensions now emit current_fuel_block_height as a string (with leading zeros trimmed) instead of a number to make the extensions payload consistent.

The Rust client is updated to deserialize current_fuel_block_height from an optional string into BlockHeight, defaulting safely when the field is absent, and a changelog entry is added for the fix.

Written by Cursor Bugbot for commit 228516c. This will update automatically on new commits. Configure here.


block_height_str.drain(..cut);
block_height_str
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unnecessary leading zero trimming is dead code

Low Severity

The block_to_trimmed_string function contains logic to trim leading zeros from a string (lines 144-152), but this code path can never execute meaningfully. In Rust, u32::to_string() never produces leading zeros - it always outputs the minimal decimal representation. The entire trimming logic is dead code that adds unnecessary complexity. The function could be simplified to just u32::from(block_height).to_string().

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

... that's not what I was getting. I was getting leading zeros and that's why I added it.

}

fn block_to_trimmed_string(block_height: BlockHeight) -> String {
let mut block_height_str = u32::from(block_height).to_string();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why we don't want to use to_string implementation of the BlockHeight?

match value {
None => Ok(None),
Some(value) => {
let parsed = value.parse::<u32>().map_err(|_| {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why can't we parse directly into BlockHeight? It implemented FromStr trait

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


block_height_str.drain(..cut);
block_height_str
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Trimmed hex string breaks BlockHeight deserialization roundtrip

High Severity

block_to_trimmed_string strips leading zeros from BlockHeight::to_string()'s hex output (e.g., "00000064""64"), but the client-side deserialize_block_height_option calls BlockHeight::from_str on this trimmed value. Since BlockHeight is a fixed-width 4-byte hex type, from_str expects exactly 8 hex characters matching the Display format. Trimmed strings like "64" (wrong byte count) or "0" (odd-length hex) will fail to parse, breaking the response deserialization for current_fuel_block_height.

Additional Locations (1)
Fix in Cursor Fix in Web

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants