Uh oh!
There was an error while loading. Please reload this page.
fix(bootstrap): reject on non-2xx tarball response and handle zlib errors - #356
fix(bootstrap): reject on non-2xx tarball response and handle zlib errors#356cs-raj wants to merge 3 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 |
Replace the generic cliux.error+rethrow pattern with a single clean Error throw so oclif prints one message. Message names both the repo and the missing cli-use branch so the developer knows exactly what to check on GitHub. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🔒 Security Scan Results
⏱️ SLA Breach Summary
✅ BUILD PASSED - All security checks passed |
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