Skip to content

fix: accept string transaction errors in Solana RPC models - #3

Open
ClancyBreach wants to merge 1 commit into
markosnarinian:mainfrom
ClancyBreach:codex/helius-rpc-error-forms
Open

ClancyBreach wants to merge 1 commit into
markosnarinian:mainfrom
ClancyBreach:codex/helius-rpc-error-forms

Conversation

@ClancyBreach

Copy link
Copy Markdown

Solana RPC transaction errors can be strings (for example, "BlockhashNotFound"), structured objects, or null. The models currently accept only objects or null, so valid string errors raise a Pydantic validation error instead of being returned to the caller.

On the current main, this reproduces the problem:

from helius.rpc.models import SignatureStatus

SignatureStatus.model_validate({
    "slot": 48,
    "confirmations": None,
    "err": "BlockhashNotFound",
    "confirmationStatus": "finalized",
})
# ValidationError: err — Input should be a valid dictionary

Extend err to str | dict | None in SignatureStatus, TransactionSignature, TransactionMetadata, and TransactionSignaturesDetail, matching the documented Solana transaction-error forms. Existing object/null values remain supported, and the field remains required.

Add 40 parametrized regression cases covering all four models and their client parsing paths, successful responses, string/object errors, invalid primitive values, and missing fields. HTTP responses are simulated with respx using synthetic fixtures based on documented RPC response shapes.

Validation on Python 3.11.9:

  • Full suite: 224 passed, with network sockets disabled.
  • Before the fix, the eight new string-error model/client cases failed as expected.
  • basedpyright, isort, CI fatal-error flake8 checks, new-test style checks, and scoped Black checks passed.
  • Full-source Black still flags the pre-existing formatting of the unchanged src/helius/laserstream/websockets.py.

No public SDK methods or dependencies are changed. No live RPC requests or blockchain transactions were used.

This branch has not been deployed

No deployments
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