Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copilot provider doesn't handle body arriving in a different message than the headers #517

Open
jhrozek opened this issue Jan 8, 2025 · 1 comment · May be fixed by #523
Open

copilot provider doesn't handle body arriving in a different message than the headers #517

jhrozek opened this issue Jan 8, 2025 · 1 comment · May be fixed by #523
Assignees

Comments

@jhrozek
Copy link
Contributor

jhrozek commented Jan 8, 2025

in _forward_data_to_target in the copilot pipeline we pass the data through the pipeline always even if we only receive headers in one message and the body in the subsequent message. This causes the first request (headers) to bypass the pipeline because the body is empty and the request to fail in case e.g. the server checks if the body is valid JSON.

Since our pipeline needs the complete body of the request anyway, we need to buffer the whole body before forwarding it to the pipeline (if we didn't have the pipeline, we could probably just start writing the body in chunks as soon as the first piece of the body arrived)

@jhrozek jhrozek added the bug label Jan 8, 2025
@jhrozek
Copy link
Contributor Author

jhrozek commented Jan 8, 2025

Blocking #402

@jhrozek jhrozek self-assigned this Jan 8, 2025
jhrozek added a commit to jhrozek/codegate-open that referenced this issue Jan 9, 2025
…eceived the whole body

It might happen that the proxied request arrives in two chunks - first
just the headers and then the body. In that case we would have sent just
the headers with an empty body through the pipeline which might trigger
errors like "400 Client Error", then the body would arrive in the next
chunk.

This patch changes the logic to keep the whole body in the buffer until
it is complete and can be processed by the pipeline and sent off to the
server.

Fixes: stacklok#517
@jhrozek jhrozek linked a pull request Jan 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant