Skip to content

fix(http): append debug request body chunks instead of overwriting#2875

Merged
tusharmath merged 2 commits intomainfrom
request-debug-append
Apr 7, 2026
Merged

fix(http): append debug request body chunks instead of overwriting#2875
tusharmath merged 2 commits intomainfrom
request-debug-append

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 7, 2026

Summary

Change the HTTP debug request body writer to use append mode instead of overwrite, so that multiple streamed chunks accumulate into a single debug file rather than each chunk replacing the previous one.

Context

When debugging HTTP requests, the body is written to a file for inspection. Previously, each chunk of the request body would call write, overwriting the file contents with only the latest chunk. For streamed or chunked request bodies, this meant only the last chunk was visible in the debug file, making it impossible to inspect the full request payload.

Changes

  • Added append method to the FileWriterInfra trait and all its implementations (ForgeFS, ForgeFileWriteService, ForgeInfra, ForgeRepo)
  • Switched the HTTP debug body writer from write to append, so chunks accumulate in the file
  • Updated all mock/test implementations of FileWriterInfra to include the new append method

Key Implementation Details

The ForgeFS::append function opens the file with create(true) and append(true) flags via tokio::fs::OpenOptions, ensuring the file is created on first write and subsequent writes are appended. Parent directories are created automatically before appending (consistent with the existing write behaviour). The HTTP layer spawns a tokio::spawn task that calls append for every chunk, so the full body is assembled in order.

Testing

# Run the affected crate tests
cargo insta test --accept -p forge_infra
cargo insta test --accept -p forge_services
cargo insta test --accept -p forge_repo

# Enable HTTP debug mode and make a streaming request, then inspect the debug file
# to confirm all chunks are present
FORGE_HTTP_DEBUG=1 cargo run -- <your-command>

@tusharmath tusharmath changed the title request debug append fix(http): append debug request body chunks instead of overwriting Apr 7, 2026
@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 7, 2026
@tusharmath tusharmath enabled auto-merge (squash) April 7, 2026 03:38
@tusharmath tusharmath merged commit 27124d7 into main Apr 7, 2026
9 checks passed
@tusharmath tusharmath deleted the request-debug-append branch April 7, 2026 03:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant