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

Return error on empty Google receipt PackageName #1085

Merged
merged 1 commit into from
Sep 12, 2023

Conversation

sesposito
Copy link
Member

No description provided.

@@ -283,6 +283,10 @@ func decodeReceiptGoogle(receipt string) (*ReceiptGoogle, error) {
if err := json.Unmarshal([]byte(unwrapped), &gr); err != nil {
return nil, errors.New("receipt is malformed")
}
if gr.PackageName == "" {
return nil, errors.New("receipt is malformed")
Copy link
Contributor

Choose a reason for hiding this comment

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

would it make the error more useful if we actually returned the reason (like in package name is empty) here?

Copy link
Member Author

Choose a reason for hiding this comment

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

being purposefully generic as this field should always be present if the receipt is in the expected format, otherwise valid json is unmarshalled without error but the struct will have none of the expected fields set.

@sesposito sesposito merged commit 18e37bc into master Sep 12, 2023
3 checks passed
@sesposito sesposito deleted the spe/malformed-receipt-error branch September 12, 2023 16:09
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