Skip to content

Set accept header to application/octet-stream for downloading package tarballs - #63

Merged
cmoesel merged 2 commits into
mainfrom
header-fix
Oct 31, 2026
Merged

cmoesel merged 2 commits into
mainfrom
header-fix

Conversation

@GinoCanessa

Copy link
Copy Markdown
Contributor

Description:

Explicitly request Accept: application/octet-stream when downloading package tarballs through FHIRRegistryClient, using both Axios and the HTTPS/browser transport. JSON metadata requests keep their original config.

Setting Axios's responseType: 'stream' does not override the default Accept: application/json, text/plain, */* header. With those defaults, packages2 can return the JSON metadata instead of a tarball. FPL attempts to extract the metadata as an archive, causing TAR_BAD_ARCHIVE and a generic download failure.

Discovered against hl7.fhir.r6.core#6.0.0-snapshot1, where the primary registry returns 404 and the fallback required an explicit binary-content request. Existing cached package contents masks the failure.

Regression coverage checks the Axios archive header, unchanged JSON metadata lookups, the HTTPS archive header, and a primary-404/fallback scenario that returns metadata unless binary content is requested. Cache behavior is unchanged; no existing cache contents were modified.

Note that the packages2 server is also receiving a fix for this issue - I continued the PR to ensure we do not run into this on generic NPM servers or updated configurations in the future.

Testing Instructions:

Targeted registry and HTTP utility tests: passed (6 suites, 82 tests).

npm test -- --runInBand --coverage=false --runTestsByPath test\registry\FHIRRegistryClient.test.ts test\registry\DefaultRegistryClient.test.ts test\registry\NPMRegistryClient.test.ts test\registry\RedundantRegistryClient.test.ts test\registry\utils.test.ts test\utils\axiosUtils.test.ts

Build, lint, and formatting: all passed.

npm run build
npm exec --no -- eslint src\registry\FHIRRegistryClient.ts test\registry\FHIRRegistryClient.test.ts test\registry\DefaultRegistryClient.test.ts
npm exec --no -- prettier --check src\registry\FHIRRegistryClient.ts test\registry\FHIRRegistryClient.test.ts test\registry\DefaultRegistryClient.test.ts

The full test suite was not run.

Related Issue:

None linked.

#committers > Build Failure @ 💬

@GinoCanessa
GinoCanessa requested a review from cmoesel October 15, 2026 21:57
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 29943128-aaf7-4f58-97a1-694feb5e183c

@cmoesel cmoesel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution. I wish we had done this sooner!

@cmoesel
cmoesel merged commit 916bd9f into main Oct 31, 2026
14 checks passed
@cmoesel
cmoesel deleted the header-fix branch October 31, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants