Skip to content

fix(brand-builder): strict Content-Encoding + parallel-safe test fixtures - #3598

Merged
bokelley merged 1 commit into
mainfrom
bokelley/parse-followups
Apr 30, 2026
Merged

bokelley merged 1 commit into
mainfrom
bokelley/parse-followups

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Followups to #3396 from the post-merge expert reviews.

What ships

1. Strict Content-Encoding check on the parse URL fetch path (server/src/routes/brand-feeds.ts)

The compression-bomb defense in #3396 sends Accept-Encoding: identity to disable undici's auto-decompression. The expert review flagged a residual gap: a hostile server can ignore that header and ship gzip/br/deflate anyway — undici still decodes, and the 1MB streaming cap measures decompressed bytes, leaving a high-ratio bomb path open.

Now rejects any response where Content-Encoding is set to anything other than identity (or absent) before reading the body.

2. PID + timestamp suffixed test fixture IDs (server/tests/integration/brand-properties-parse.test.ts)

Hardcoded constants like org_parse_owner_001 collide with sibling integration suites under parallel execution. Suffix with process.pid + Date.now() so each worker gets isolated rows. Suggested by the nodejs-testing-expert pass on #3396.

Tests

31 cases passing (was 26). 5 new:

  • 4 cases for Content-Encoding ∈ {gzip, br, deflate, GZIP} rejection (case-insensitive)
  • 1 case for explicit Content-Encoding: identity acceptance

Followups not in scope (will file separately)

🤖 Generated with Claude Code

Followup to PR #3396. The Accept-Encoding: identity request header
disables undici auto-decompression, but a hostile server can ignore it
and ship gzip/br/deflate anyway — undici still decodes, and the 1MB
streaming cap measures decompressed bytes. A high-ratio bomb spikes
memory before the cap fires.

Now reject responses where Content-Encoding is anything other than
identity (or absent) before reading the body. Server can't bypass.

Also derive test fixture IDs from process.pid + Date.now() so parallel
integration suites don't FK-conflict on shared organizations/users/
brands rows. Suggested by the nodejs-testing-expert review.

5 new tests cover gzip/br/deflate rejection (case-insensitive) plus
an explicit identity acceptance case.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit 39139ff into main Apr 30, 2026
13 checks passed
@bokelley
bokelley deleted the bokelley/parse-followups branch April 30, 2026 01:48
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.

1 participant