Support decoder:"body" tag for raw request body capture#81
Support decoder:"body" tag for raw request body capture#81google-labs-jules[bot] wants to merge 1 commit intomainfrom
decoder:"body" tag for raw request body capture#81Conversation
Added support for capturing the raw request body into struct fields using the `decoder:"body"` tag. This functionality works independently of registered content-type decoders and supports capturing the body as `[]byte` or `io.Reader`. * Modified `internal/cache/structure.go` to detect the `decoder:"body"` tag. * Modified `roamer.go` to handle body preservation and assignment for tagged fields. * Ensured `req.Body` is correctly managed (preserved/restored) during the process. * Added comprehensive table-driven tests covering success and failure scenarios.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
Pull Request Test Coverage Report for Build 19783589881Details
💛 - Coveralls |
|
Claude finished @slipros's task in 1m 23s —— View job Code ReviewI've reviewed the PR that adds support for SummaryThe implementation is well-designed and functional, with good test coverage (92.86%). The code correctly handles the new feature while maintaining backward compatibility. However, there are several areas that need attention. Critical Issues1. Memory Efficiency Concern -
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if readerErr := assign.Value(fieldValue, reader, r.assignExtensions...); readerErr != nil { | ||
| return errors.Wrapf(err, "set `body` value to field `%s` in struct `%T`", f.Name, ptr) |
There was a problem hiding this comment.
PreserveBody skipped on body-tag assignment errors
If assigning a decoder:"body" field fails, the function returns from this branch before reaching the restoration block at the end of parseBody, so with WithPreserveBody enabled the request body stays consumed when an assignment error occurs after a successful decode (e.g., a decoder:"body" field typed as int). Downstream handlers that rely on a preserved body will hit EOF even though preservation was requested.
Useful? React with 👍 / 👎.
Implemented support for
decoder:"body"tag to allow capturing the raw request body into struct fields ([]byteorio.Reader).Key changes:
internal/cache/structure.goto analyze and cache fields with thedecoder:"body"tag.roamer.go'sparseBodymethod to:preserveBodyis enabled).decoder:"body"using either the raw bytes or a newbytes.Reader.req.Bodybased on the globalpreserveBodysetting.roamer_body_decoder_test.gowith table-driven tests verifying:[]byte.io.Reader.preserveBodyoption.PR created automatically by Jules for task 17099098357886983700 started by @slipros