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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build status Shield returns invalid response data #6235

Closed
1 of 3 tasks
fmigneault opened this issue Mar 1, 2021 · 3 comments
Closed
1 of 3 tasks

Docker build status Shield returns invalid response data #6235

fmigneault opened this issue Mar 1, 2021 · 3 comments
Labels
bug Bugs in badges and the frontend good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs

Comments

@fmigneault
Copy link

Are you experiencing an issue with...

馃 Description

Something doesn't work about the first docker shield below.
I'm not sure if it is related to the automated/manual build method, but status cannot be retrieved.
Same link format but replacing the target repository works for another repo I work on.

馃敆 Link to the badge

https://img.shields.io/docker/cloud/build/pavics/weaver.svg
Docker Cloud Build Status

https://img.shields.io/docker/automated/pavics/weaver.svg
Docker Cloud Build Status

https://img.shields.io/docker/cloud/build/pavics/magpie.svg
Docker Cloud Build Status

https://img.shields.io/docker/automated/pavics/magpie.svg
Docker Cloud Build Status

馃挕 Possible Solution

@fmigneault fmigneault added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Mar 1, 2021
@calebcartwright calebcartwright added good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs and removed question Support questions, usage questions, unconfirmed bugs, discussions, ideas labels Mar 2, 2021
@calebcartwright
Copy link
Member

Thanks for the report! The invalid response data error is what happens when an upstream API response was something we were not expecting and unprepared for.

The API calls made for the two referenced repositories:
https://hub.docker.com/api/build/v1/source/?image=pavics/weaver
https://hub.docker.com/api/build/v1/source/?image=pavics/magpie

In the case of pavics/weaver, the objects array is empty while our code was expecting/reliant on there being at least one entry, as that's where the data for build status is found. We can update our schema validation that inspects the response from the DockerHub API to better handle this scenario since it's obviously a possible response, although TBH I'm not really sure what the message should be here, maybe throw some kind of error indicating automated builds haven't been setup for that repo?

I've marked this as a good-first-issue because the code change is relatively straightforward, though admittedly some TBD on what the error/text message of the badge should be

The schema can be found here, and the easiest fix would probably be to remove the .required() call chain on the object on line 11.

const cloudBuildSchema = Joi.object({
objects: Joi.array()
.items(
Joi.object({
state: Joi.string(),
build_settings: Joi.array(),
}).required()
)
.required(),
}).required()

There would then be a need to check added to account for the empty objects array and act accordingly. I'd think we'd want to do that in the cloud build service for this issue, https://github.com/badges/shields/blob/master/services/docker/docker-cloud-build.service.js and throw an error in the case of an empty array, whereas in the cloud automated build service we'd want to incorporate that possibility to properly indicate it as manual https://github.com/badges/shields/blob/master/services/docker/docker-cloud-automated.service.js

(note that the badges in the issue description are using the older/legacy route which ironically still work, but the same invalid response issue exists for the cloud automated badge https://img.shields.io/docker/cloud/automated/pavics/weaver )

@fmigneault
Copy link
Author

@calebcartwright
I see. Makes sense since there are no build details.
A specific message for this case would help indeed, but I agree that there is not much more that can be done with returned content.
Thanks!

@paulmelnikow paulmelnikow added the bug Bugs in badges and the frontend label Jul 9, 2021
@PaulaBarszcz
Copy link
Collaborator

I'd like to pick this one up :)

The badge error message for https://img.shields.io/docker/cloud/build/pavics/weaver.svg
can say automated builds not set up, as per @calebcartwright's suggestion (unless there are some other ideas?).

@calebcartwright wrote:

There would then be a need to check added to account for the empty objects array and act accordingly. I'd think we'd want to do that in the cloud build service for this issue, https://github.com/badges/shields/blob/master/services/docker/docker-cloud-build.service.js and throw an error in the case of an empty array, whereas in the cloud automated build service we'd want to incorporate that possibility to properly indicate it as manual https://github.com/badges/shields/blob/master/services/docker/docker-cloud-automated.service.js

Will do :) 馃憤

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 good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

No branches or pull requests

4 participants