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

Liberapay Badge shows "invalid response data" #6254

Closed
1 of 3 tasks
fschrempf opened this issue Mar 10, 2021 · 4 comments · Fixed by #6258
Closed
1 of 3 tasks

Liberapay Badge shows "invalid response data" #6254

fschrempf opened this issue Mar 10, 2021 · 4 comments · Fixed by #6258
Labels
bug Bugs in badges and the frontend

Comments

@fschrempf
Copy link

Are you experiencing an issue with...

🪲 Description

My Liberapay badges don't work and just show "invalid response data", though the data is accessible at https://liberapay.com/frsc/public.json. Badges of other users seem to work fine.

🔗 Link to the badge

Badge

https://img.shields.io/liberapay/gives/frsc.svg?logo=liberapay

@fschrempf fschrempf added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Mar 10, 2021
@calebcartwright
Copy link
Member

Thanks for reaching out. Our schema validation (used to process the response) is expecting the goal key to always exist, even if it has a null value. For some reason, the response for your entity does not have the goal key at all, which is causing the response validation to fail.

If the absence of the goal key is an expected/valid scenario, then we'd need to update our schema accordingly

const schema = Joi.object({
npatrons: nonNegativeInteger,
giving: Joi.object()
.keys({
amount: Joi.string().required(),
currency: Joi.string().required(),
})
.allow(null)
.required(),
receiving: Joi.object()
.keys({
amount: Joi.string().required(),
currency: Joi.string().required(),
})
.allow(null)
.required(),
goal: Joi.object()
.keys({
amount: Joi.string().required(),
})
.allow(null)
.required(),
}).required()

@chris48s chris48s added bug Bugs in badges and the frontend and removed question Support questions, usage questions, unconfirmed bugs, discussions, ideas bug Bugs in badges and the frontend labels Mar 10, 2021
@chris48s
Copy link
Member

Looking at the liberapay source/tests, it is expected that in some situations public.json will not include a "goal" key e.g:
https://github.com/liberapay/liberapay.com/blob/ca814ed2478108b119fef4498a8ee521a5553914/tests/py/test_public_json.py#L38-L41

We should split the schema for liberapay so that only the goal badge fails if there's no goal key - badges that don't need it shouldn't fail if it is not there.

@Changaco
Copy link

I suggest simply removing the .required() call in the schema. The goal badge should then error with the message "no public goals" when the goal is missing.

chris48s added a commit to chris48s/shields that referenced this issue Mar 11, 2021
repo-ranger bot added a commit that referenced this issue Mar 12, 2021
* allow missing 'goal' key in [liberapay] badges

closes #6254

* fix test name

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
@fschrempf
Copy link
Author

Thanks for fixing, works as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs in badges and the frontend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants