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

json: cannot unmarshal number into Go struct field RevokeSponsorship.offer_id of type string #3081

Closed
bartekn opened this issue Sep 30, 2020 · 7 comments

Comments

@bartekn
Copy link
Contributor

bartekn commented Sep 30, 2020

What version are you using?

1.9.0

What did you do?

Found this transaction when checking the logs:
https://horizon-protocol14.stellar.org/transactions/36c0f3aaf915667f3a15ef2bba2df4496f17a78e82112e58d26deef6dc203957 it's /operations return 500:
https://horizon-protocol14.stellar.org/transactions/36c0f3aaf915667f3a15ef2bba2df4496f17a78e82112e58d26deef6dc203957/operations
and the following error:

json: cannot unmarshal number into Go struct field RevokeSponsorship.offer_id of type string
@bartekn
Copy link
Contributor Author

bartekn commented Sep 30, 2020

OK, I think it was fixed in #3072. @2opremio you can close this if it's the same bug.

@2opremio
Copy link
Contributor

I do think it's the same bug but... could you test on testnet to be sure?

@bartekn
Copy link
Contributor Author

bartekn commented Oct 1, 2020

The problem is here. We save the offer_id as string:

result["offer_id"] = fmt.Sprintf("%d", ledgerKey.Offer.OfferId)

but then it's unmarshaled into int64:
OfferID *int64 `json:"offer_id,omitempty,string"`

@2opremio
Copy link
Contributor

2opremio commented Oct 1, 2020

@bartekn note the string tag (i.e. it will accept a string even if it's an int64). I tested it.

Also, you were testing it on the 1.9 RC and not on the the GA release. I do think it's the same bug but I will eat my hat if you reproduce it on testnet (with the 1.9 final release)

@2opremio
Copy link
Contributor

2opremio commented Oct 1, 2020

PS: it's being tested at

@bartekn bartekn added this to the Horizon 1.10.0 milestone Oct 1, 2020
@abuiles
Copy link
Contributor

abuiles commented Oct 2, 2020

@2opremio @bartekn I smoke test this in testnet and the problem is fixed - https://horizon-testnet.stellar.org/transactions/02a69bb0dc83d004ae918aab2d10c9dbc2cbf4451ab12927a691b87e5c6c5079/operations

The string tag @2opremio pointed above does the right thing and also the PR where the fixed was introduced mentions this specific scenario: * Fix type for RevokeSponsorship's OfferID field, which was causing a 500 error on /operations due to an unmarshalling error.

@abuiles abuiles closed this as completed Oct 2, 2020
@bartekn
Copy link
Contributor Author

bartekn commented Oct 5, 2020

@abuiles thanks for checking!

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

No branches or pull requests

3 participants