Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC returns unfilled response fields with default Go values #354

Open
leighmcculloch opened this issue Jan 29, 2025 · 2 comments
Open

RPC returns unfilled response fields with default Go values #354

leighmcculloch opened this issue Jan 29, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@leighmcculloch
Copy link
Member

leighmcculloch commented Jan 29, 2025

What version are you using?

22.1.0-c7e9737b54913f5a33f29decdb0c9f6101dc1cfc

What did you do?

$ curl -X POST \
-H 'Content-Type: application/json' \
-d '{
  "jsonrpc": "2.0",
  "id": 8675309,
  "method": "getTransaction",
  "params": {
    "hash": "6bc97bddc21811c626839baf4ab574f4f9f7ddbebb44d286ae504396d4e752da"
  }
}' \
https://soroban-testnet.stellar.org/ | jq

What did you expect to see?

Docs says this should be the result, and that for most of the fields in the response that:

This field is only present if status is SUCCESS or FAILED.

{
  "jsonrpc": "2.0",
  "id": 8675309,
  "result": {
    "status": "NOT_FOUND",
    "latestLedger": 2540099,
    "latestLedgerCloseTime": "1700086455",
    "oldestLedger": 2538660,
    "oldestLedgerCloseTime": "1700078913"
  }
}

Ref: https://developers.stellar.org/docs/data/rpc/api-reference/methods/getTransaction

What did you see instead?

{
  "jsonrpc": "2.0",
  "id": 8675309,
  "result": {
    "latestLedger": 861017,
    "latestLedgerCloseTime": "1738160526",
    "oldestLedger": 740058,
    "oldestLedgerCloseTime": "1737555056",
    "status": "NOT_FOUND",
    "txHash": "6bc97bddc21811c626839baf4ab574f4f9f7ddbebb44d286ae504396d4e752da",
    "applicationOrder": 0,
    "feeBump": false,
    "ledger": 0,
    "createdAt": "0"
  }
}

Interestingly the fields don’t appear when using the js-stellar-sdk, but do appear when using the raw js fetch example, so the sdk must be hiding the fields.

Ah, yes, we seem to hide the extra fields in the js-stellar-sdk when the response is received here:

Seems like an rpc bug to me though. Sdk hides the fields, so intent is for folks not to see it, but if we live “apis over sdks” the api should lead first with hiding the fields so sdks don’t have to, and folks who don’t use the sdks don’t see it.

Discussion:

@leighmcculloch leighmcculloch added the bug Something isn't working label Jan 29, 2025
@2opremio
Copy link
Contributor

I don't think it's an RPC bug just because the SDK doesn't expose the fields

@Shaptic
Copy link
Contributor

Shaptic commented Jan 29, 2025

The SDK doesn't intentionally "hide" the fields, it interprets the raw response in alignment with the documentation, which states certain fields are only present if status != "NOT_FOUND". They are hidden insofar as the SDK cannot rely on them existing for parsing per the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants