fix(api): reject non-multipart uploads with 400, harden CI key recipes - #10
Merged
Merged
Conversation
Busboy's constructor throws a plain synchronous Error (seen in production as "Missing Content-Type") when an upload request lacks a multipart Content-Type header; it also throws for a wrong content type or a missing boundary. These surfaced as 500 "failure while serving http request" logs. Validate the Content-Type before constructing busboy in both upload helpers and map any remaining constructor throw to a 400. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HsLRNvcquWp1ZKjfJUuET3
A key pasted into a CI secret with a trailing line break lands verbatim in the x-api-key header and corrupts the HTTP request — depending on curl/server versions the header block is terminated early, so the registry sees the upload without its multipart Content-Type header (the "Missing Content-Type" 500s seen in production). Sanitize the key with `tr -d '[:space:]'` before the curl call in the publish-plugin composite action and in all five documented CI recipes, and document the gotcha in the API key setup section. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HsLRNvcquWp1ZKjfJUuET3
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.
Production logs showed
Error: Missing Content-Type500s from the upload endpoints, paired with clientParse Errors. Root cause: an API key pasted into a CI secret with a trailing newline lands verbatim in thex-api-keyheader and corrupts the HTTP request — the registry then sees the upload without its multipartContent-Typeheader, and busboy's constructor throws a plainErrorthat surfaced as a 500.POST /artefacts/npm/:idand/artefacts/file/:namenow validate the Content-Type before constructing busboy and map any remaining synchronous busboy constructor throw (wrong type, missing boundary) to a 400 with a readable message. Regression tests cover missing and non-multipart Content-Type on both endpoints.publish-pluginshared action and all five documented CI recipes strip whitespace from the key before the curl call, and the gotcha is documented at the key-copy step.data-upstream/(the upstream registry's scan-cache extractions were restarting both dev APIs mid-test, causing ECONNRESET flakes in the sync spec), plus regenerated ui auto-imports (unrelated drift, no functional change).Regression risks: