Skip to content

fix: TransactionFee model rejects string gasPrice/baseFee/priorityFee from API#136

Open
jacklatourette wants to merge 1 commit intofireblocks:masterfrom
jacklatourette:fix/transaction-fee-strict-type-mismatch
Open

fix: TransactionFee model rejects string gasPrice/baseFee/priorityFee from API#136
jacklatourette wants to merge 1 commit intofireblocks:masterfrom
jacklatourette:fix/transaction-fee-strict-type-mismatch

Conversation

@jacklatourette
Copy link
Copy Markdown

Summary

The Fireblocks API returns gasPrice, baseFee, and priorityFee as strings (e.g. "1", "0.005") in the estimate_transaction_fee response. However, the TransactionFee Pydantic model declares these fields as Optional[Union[StrictFloat, StrictInt]].

StrictFloat and StrictInt reject string inputs without coercion, so Pydantic validation fails with errors like:

6 validation errors for TransactionFee
gasPrice.float
  Input should be a valid number [type=float_type, input_value='1', input_type=str]
gasPrice.int
  Input should be a valid integer [type=int_type, input_value='1', input_type=str]
baseFee.float
  Input should be a valid number [type=float_type, input_value='0.005', input_type=str]
...

The SDK then falls back to returning an UnknownBaseModel instead of EstimatedTransactionFeeResponse, which breaks downstream attribute access like response.medium.network_fee.

Fix

Add StrictStr to the union type for gas_price, base_fee, and priority_fee:

# Before
gas_price: Optional[Union[StrictFloat, StrictInt]]

# After
gas_price: Optional[Union[StrictFloat, StrictInt, StrictStr]]

This matches the actual API response format while preserving strict validation (no implicit coercion).

Reproduction

Call estimate_transaction_fee for any EVM-based asset (e.g. Base Sepolia ETH). The API returns string values for gas fields, causing the SDK to emit a UserWarning: Failed to deserialize response of type EstimatedTransactionFeeResponse and return an UnknownBaseModel.

…actionFee

The Fireblocks API returns gasPrice, baseFee, and priorityFee as strings
(e.g. "1", "0.005") in the estimate_transaction_fee response, but the
TransactionFee model declares these fields as StrictFloat | StrictInt.

Pydantic's StrictFloat/StrictInt reject string inputs without coercion,
causing model validation to fail. The SDK then falls back to returning an
UnknownBaseModel instead of the expected EstimatedTransactionFeeResponse,
breaking downstream attribute access (e.g. response.medium.network_fee).

Add StrictStr to the Union type for these three fields so the model
validates successfully regardless of whether the API returns numeric or
string representations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant