Skip to content

fix(http): append newline to debug file writes for valid jsonl format#2939

Merged
tusharmath merged 1 commit intomainfrom
fix-jsonl-newline
Apr 10, 2026
Merged

fix(http): append newline to debug file writes for valid jsonl format#2939
tusharmath merged 1 commit intomainfrom
fix-jsonl-newline

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 10, 2026

Summary

Fix HTTP debug file writes to append a newline after each entry, ensuring the output is valid JSONL (JSON Lines) format.

Context

When the debug_requests feature is enabled, HTTP request/response bodies are appended to a debug file. However, each write was missing a trailing newline, meaning entries were written back-to-back without any delimiter. This breaks the JSONL format, where each line must be a separate, complete JSON object. Tools that consume JSONL files (log parsers, analytics pipelines, etc.) would fail to parse the debug output correctly.

Changes

  • Updated ForgeHttpInfra to append a \n byte after each body write to the debug file, producing valid JSONL output.
  • Updated all related unit tests to reflect the new expected output (body + newline).

Key Implementation Details

The fix is minimal and targeted: before calling file_writer.append, the body bytes are cloned into a Vec<u8>, a newline byte (b'\n') is pushed, and the result is converted back to Bytes. This ensures no existing data is mutated and the change is fully backward-compatible.

Testing

# Run the affected crate's tests
cargo insta test --accept -p forge_infra

All four existing debug-write tests have been updated to assert the newline is present and continue to pass.

Links

  • Affected file: crates/forge_infra/src/http.rs

@github-actions github-actions bot added type: feature Brand new functionality, features, pages, workflows, endpoints, etc. type: fix Iterations on existing features or infrastructure. labels Apr 10, 2026
@tusharmath tusharmath enabled auto-merge (squash) April 10, 2026 17:51
@tusharmath tusharmath merged commit cf3a3ca into main Apr 10, 2026
10 checks passed
@tusharmath tusharmath deleted the fix-jsonl-newline branch April 10, 2026 17:52
@tusharmath tusharmath removed the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 10, 2026
@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 10, 2026
@tusharmath tusharmath removed the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 10, 2026
@github-actions github-actions bot added the type: feature Brand new functionality, features, pages, workflows, endpoints, etc. label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature Brand new functionality, features, pages, workflows, endpoints, etc. type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant