[PR #6906] [CLOSED] fix(analysis): treat unsupported HAR body encodings as unavailable text (#6889) #7438

Closed
opened 2026-11-01 21:47:51 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/6906
Author: @bhedanikhilkumar-code
Created: 10/23/2026
Status: ❌ Closed

Base: main ← Head: fix/issue-6889-unsupported-har-body-encoding


📝 Commits (1)

  • 0482899 fix(analysis): treat unsupported HAR body encodings as unavailable text (#6889)

📊 Changes

2 files changed (+86 additions, -1 deletions)

View changed files

➕ src/domain/analysisView/recordedResponseBody.test.ts (+83 -0)
📝 src/domain/analysisView/recordedResponseBody.ts (+3 -1)

📄 Description

Summary

Fixes #6889

Treats HAR responses declaring unsupported content encodings (such as "hex" or "base64url") as unavailable decoded text (bodyText: null) instead of incorrectly exposing raw encoded characters as decoded response text.

Problem and expected behavior

When a HAR entry declares response.content.encoding with an unsupported encoding (e.g. "hex" or "base64url"), readRecordedResponseBody previously checked if (encoding !== "base64") return { bodyText: text }. This conflated an absent/null encoding (plain decoded text) with unsupported declared encodings, causing raw encoded representations (e.g., "68656c6c6f" or "aGVsbG8") to be returned as decoded bodyText and replayed as ordinary text.

The expected behavior is that unsupported declared encodings keep bodyText: null (and replay body as none), preserving the original reported fields in evidence without treating encoded characters as decoded text.

Change and scope

  • In src/domain/analysisView/recordedResponseBody.ts:
    • Updated readRecordedResponseBody to distinguish absent/null encoding from unsupported declared encodings.
    • Returns { bodyText: null } whenever encoding is defined, non-null, and not "base64".
    • Preserves { bodyText: text } when encoding is undefined or null.
  • In src/domain/analysisView/recordedResponseBody.test.ts:
    • Added unit test cases covering absent encoding, null encoding, base64 decoding, and unsupported encodings (hex, base64url, gzip, deflate).

Follow the contribution scope: Ordinary fix within existing domain response-body reader boundaries; maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/domain/analysisView/recordedResponseBody.ts.
  • Contribution scope fit and linked maintainer decision: not applicable (within existing domain boundaries).
  • CLI and MCP/tool-catalog contract: Unchanged; response body reader no longer misrepresents unsupported encoded strings as decoded text.
  • Provider, bridge, target-format, or platform compatibility: Compliant with HAR 1.2 content encoding specification.
  • Evidence, artifact, provenance, or reconstruction contract: Preserves raw reported fields in evidence while signaling unavailable body text to downstream consumers.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated:
    • src/domain/analysisView/recordedResponseBody.test.ts: Added tests verifying absent/null encoding returns decoded text, valid base64 decodes UTF-8, and unsupported encodings (hex, base64url, etc.) return { bodyText: null }.
  • Base reproduction or other evidence: Verified that encoding: "hex" and "base64url" previously returned encoded characters in bodyText and now return { bodyText: null }.
  • User-visible CLI/MCP output: Downstream replay and state extraction do not mistake encoded strings for decoded plain text.
  • Remaining proof gaps: none.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:local -- src/domain/analysisView/recordedResponseBody.test.ts src/application/environment/environmentSource.test.ts — 14 passed
  • npm run check:fast — passed (turbo typecheck and lint)

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Fixes bug where unsupported encodings were masquerading as plain text.
  • Real Hopper/Ghidra, browser, or OS coverage: Validated in Node.js against web network capture records.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: Prevents corrupted encoded data from being treated as valid plaintext in replay.

Author readiness

Human owner: @bhedanikhilkumar-code

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/6906 **Author:** [@bhedanikhilkumar-code](https://github.com/bhedanikhilkumar-code) **Created:** 10/23/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/issue-6889-unsupported-har-body-encoding` --- ### 📝 Commits (1) - [`0482899`](https://github.com/morluto/rea/commit/04828997992014624621e84a8eb2fdc0e8b117f5) fix(analysis): treat unsupported HAR body encodings as unavailable text (#6889) ### 📊 Changes **2 files changed** (+86 additions, -1 deletions) <details> <summary>View changed files</summary> ➕ `src/domain/analysisView/recordedResponseBody.test.ts` (+83 -0) 📝 `src/domain/analysisView/recordedResponseBody.ts` (+3 -1) </details> ### 📄 Description ## Summary Fixes #6889 Treats HAR responses declaring unsupported content encodings (such as `"hex"` or `"base64url"`) as unavailable decoded text (`bodyText: null`) instead of incorrectly exposing raw encoded characters as decoded response text. ## Problem and expected behavior When a HAR entry declares `response.content.encoding` with an unsupported encoding (e.g. `"hex"` or `"base64url"`), `readRecordedResponseBody` previously checked `if (encoding !== "base64") return { bodyText: text }`. This conflated an absent/null encoding (plain decoded text) with unsupported declared encodings, causing raw encoded representations (e.g., `"68656c6c6f"` or `"aGVsbG8"`) to be returned as decoded `bodyText` and replayed as ordinary text. The expected behavior is that unsupported declared encodings keep `bodyText: null` (and replay body as `none`), preserving the original reported fields in evidence without treating encoded characters as decoded text. ## Change and scope - In `src/domain/analysisView/recordedResponseBody.ts`: - Updated `readRecordedResponseBody` to distinguish absent/null encoding from unsupported declared encodings. - Returns `{ bodyText: null }` whenever `encoding` is defined, non-null, and not `"base64"`. - Preserves `{ bodyText: text }` when `encoding` is `undefined` or `null`. - In `src/domain/analysisView/recordedResponseBody.test.ts`: - Added unit test cases covering absent encoding, null encoding, base64 decoding, and unsupported encodings (`hex`, `base64url`, `gzip`, `deflate`). Follow the contribution scope: Ordinary fix within existing domain response-body reader boundaries; maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/domain/analysisView/recordedResponseBody.ts`. - Contribution scope fit and linked maintainer decision: not applicable (within existing domain boundaries). - CLI and MCP/tool-catalog contract: Unchanged; response body reader no longer misrepresents unsupported encoded strings as decoded text. - Provider, bridge, target-format, or platform compatibility: Compliant with HAR 1.2 content encoding specification. - Evidence, artifact, provenance, or reconstruction contract: Preserves raw reported fields in evidence while signaling unavailable body text to downstream consumers. - Target selection, authority, upstream behavior, and cleanup details (if applicable): none. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none. Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated: - `src/domain/analysisView/recordedResponseBody.test.ts`: Added tests verifying absent/null encoding returns decoded text, valid base64 decodes UTF-8, and unsupported encodings (`hex`, `base64url`, etc.) return `{ bodyText: null }`. - Base reproduction or other evidence: Verified that `encoding: "hex"` and `"base64url"` previously returned encoded characters in `bodyText` and now return `{ bodyText: null }`. - User-visible CLI/MCP output: Downstream replay and state extraction do not mistake encoded strings for decoded plain text. - Remaining proof gaps: none. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:local -- src/domain/analysisView/recordedResponseBody.test.ts src/application/environment/environmentSource.test.ts` — 14 passed - `npm run check:fast` — passed (turbo typecheck and lint) ## Compatibility, safety, and release - Breaking changes or migration steps: none. Fixes bug where unsupported encodings were masquerading as plain text. - Real Hopper/Ghidra, browser, or OS coverage: Validated in Node.js against web network capture records. - Package or release metadata impact: none. - Security, privacy, process, or containment review: Prevents corrupted encoded data from being treated as valid plaintext in replay. ## Author readiness Human owner: @bhedanikhilkumar-code - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:51 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#7438
No description provided.