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

fix(config): fail builds if failed to fetch extensions #6008

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

YujohnNattrass
Copy link
Contributor

@YujohnNattrass YujohnNattrass commented Jan 8, 2025

🎉 Thanks for submitting a pull request! 🎉

Summary

A previous PR was shipped however it was reverted when I notice some of my builds were missing integrations.

In the previous PR, we checked the Content-Length header to determine if the response body was empty and returned an empty array in such cases. However, if a site has many extensions, the response will not include the Content-Length header due to chunked encoding. The team I was working with, which has 47 extensions, experienced this issue and was missing the Content-Length header.

image

image

Tested build using this build image from this PR


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures
    we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
    something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures
    your code follows our style guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

Copy link
Contributor

github-actions bot commented Jan 8, 2025

This pull request adds or modifies JavaScript (.js, .cjs, .mjs) files.
Consider converting them to TypeScript.

@YujohnNattrass YujohnNattrass marked this pull request as ready for review January 8, 2025 23:48
@YujohnNattrass YujohnNattrass requested a review from a team as a code owner January 8, 2025 23:48
throw new Error(`Unexpected status code ${response.status} from fetching extensions`)
}
const bodyText = await response.text()
if (bodyText === '') {
Copy link
Member

Choose a reason for hiding this comment

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

Does the endpoint ever return a 200 with an empty body?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks you for taking a look @eduardoboucas!

We are calling two different endpoints one for team/${accountID}/integrations/installations/meta/${siteID} which gets its response from here in jigsaw.

and site/${siteID}/integrations/safe which gets its response from here in jigsaw.

Both endpoints returns an array for a successful response.

I did it this way because it was a little confusing about how the code was written, specifically this line here about checking if the integrations is an array. On top of that when running tests, a few tests failed since the response body was and empty string and trying to parse it would throw an error.

There were a couple approaches I could have taken:

  • by checking if there is a body and returning an empty array.
  • updating all tests that failed to have the response body be [] instead of empty string. I'm not sure if it was intentional that an empty string was returned.

Do you have another suggestion?

Also would it be beneficial use a feature flag here?

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

Successfully merging this pull request may close these issues.

3 participants