fix(bootstrap): reject on non-2xx tarball response and handle zlib errors - #356
Open
cs-raj wants to merge 2 commits into
Open
fix(bootstrap): reject on non-2xx tarball response and handle zlib errors#356cs-raj wants to merge 2 commits into
cs-raj wants to merge 2 commits into
Conversation
…rors streamRelease now throws GithubError for HTTP 4xx/5xx responses instead of silently piping the error body (e.g. "404: Not Found") into the zlib decompressor. This was the root cause of the Z_DATA_ERROR crash when the cli-use branch was absent from a repo. extract now attaches an error handler directly on the zlib.createUnzip() stream. Node's pipe() does not forward stream errors, so without this listener a zlib failure emitted an unhandled error event and crashed the process rather than rejecting the Promise cleanly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
Moving cliux.loader() (spinner stop) out of finally and into catch before cliux.error() prevents the spinner's carriage-return from wiping the error line. Success path stops the spinner inline after getLatest resolves. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
csdx cm:bootstrapcrashed with an unhandledZ_DATA_ERROR(incorrect header check) when cloning the Kickstart Next.js starter app. Two bugs combined to cause this:streamRelease()did not check the HTTP response status. When thecli-usebranch was absent fromcontentstack/kickstart-next, codeload.github.com returned a404: Not Foundbody. That body stream was silently passed downstream as if it were a valid tarball.extract()had no error handler on thezlib.createUnzip()stream. Node'spipe()does not forward stream errors between stages. When zlib tried to decompress the"404: Not Found"bytes (which have no gzip magic header), it emitted anerrorevent on theUnzipinstance with no listener — causing an unhandled exception that crashed the process instead of rejecting the Promise cleanly.Relates to: DX-10257
Fix
streamRelease()— throwsGithubErrorwith the actual HTTP status code for any4xx/5xxresponse. The existingBootstrap.run()catch block already handlesGithubErrorwithstatus === 404and prints a user-friendly "Unable to find a repo" message; no caller changes needed.extract()— extracts thezlib.createUnzip()instance and attaches.on('error', reject)directly to it, so zlib errors reject the Promise rather than escaping as unhandled events.Test plan
packages/contentstack-bootstrap/test/github.test.jsstreamReleasethrowsGithubError(404)on a 404 responsestreamReleasethrowsGithubError(500)on a 500 responsestreamReleasereturns the data stream on a 200 responsestreamReleasesendsAuthorizationheader for private reposstreamReleasethrows immediately for private repos with no tokenextractrejects withZ_DATA_ERROR(not a process crash) on invalid gzip datacsdx cm:bootstrap→ Kickstart Next.js ran end-to-end successfully after the missingcli-usebranch was created on the repo🤖 Generated with Claude Code