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

Merged
merged 10 commits into from
Jan 15, 2025

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?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for the delayed response. My comment was about the fact that if we are hitting endpoints we control, then in theory we should be able to define exactly what the shape of the response body looks like for each supported status code, as opposed to having defensive coding that may obfuscate underlying problems. Like, if a successful response to those endpoints is expected to always return some data, then a 200 with an empty body feels like an unexpected case that we should probably handle as an error.

But it's not a big deal, and you can totally ship this as is! 🚢

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have a Linear ticket assigned to me to clean up the feature flag after this PR is deployed. I'll update the ticket to include your suggestions, as they make perfect sense and will help avoid confusion in the future.

@YujohnNattrass YujohnNattrass marked this pull request as draft January 13, 2025 19:32
@YujohnNattrass YujohnNattrass marked this pull request as ready for review January 15, 2025 00:30
Copy link
Contributor

@khendrikse khendrikse left a comment

Choose a reason for hiding this comment

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

This looks good to me :) I wish we had a way to test failing the extension fetch when this is deployed just to 100% test it. But the most important piece would be testing if everything works when stuff does not fail ☺️ please do a few real world tests with the feature flag on your account when it's deployed? ❤️

@YujohnNattrass
Copy link
Contributor Author

This looks good to me :) I wish we had a way to test failing the extension fetch when this is deployed just to 100% test it. But the most important piece would be testing if everything works when stuff does not fail ☺️ please do a few real world tests with the feature flag on your account when it's deployed? ❤️

@khendrikse I tested with buildbot using my build image but just to be safe, I'll confirm test again once it has been deployed to production :)

@YujohnNattrass YujohnNattrass enabled auto-merge (squash) January 15, 2025 19:02
@YujohnNattrass YujohnNattrass merged commit 95c4716 into main Jan 15, 2025
33 checks passed
@YujohnNattrass YujohnNattrass deleted the yj/fail-builds-when-failed-to-fetch-extensions branch January 15, 2025 19:19
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.

4 participants