HTTP 431 (Request Headers too long) being caused by x-goog-api-client
becoming longer and longer
#1106
-
Hi everyone! I have a strange case of getting sporadic HTTP 431 errors using the langchain-google-vertexai integration. Specifically, a portion of the wiretap identifies the following header in particular. Only a snippet is shown since that is all was captured in the log, but the total length exceeded 8K (without me knowing how long it actually is). 8K was the point at which errors began to be registered.
Broken down, it looks like
I'm not sure how to resolve this issue (or if there is a resolution). There have been longstanding reports of Below are some details that I have discovered:
My questions are two-fold: a. How does this impact a long-running application that is using the same VertexAI / ChatVertexAI b. We use asyncio heavily. In the snippet above, the final call that exceeded the allowed header length was gemini-2.0-flash, but seeing the I'm hoping someone might be able to point me towards the right direction. Thank you in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
It looks like what you’re hitting isn’t just a header-length bug, it’s a systemic accumulation problem. The tricky part is that patching it at the HTTP layer doesn’t solve the underlying leak — the fix has to be applied at the orchestration layer so the client doesn’t keep multiplying state. If you want, I can point you to the full failure catalog where this category is broken down with permanent fixes. Let me know and I’ll share it. |
Beta Was this translation helpful? Give feedback.
-
This is great! Thank you so much! I will mark your post as the answer when I get back after the holiday! 🙏
|
Beta Was this translation helpful? Give feedback.
got it. here’s the catalog link. this case usually maps to No.14 “Bootstrap ordering” in my notes, where a long-lived client keeps accumulating per-call metadata and the fix must be at the orchestration layer, not at HTTP.
Link: [WFGY Problem Map — README]
quick checks you can try right now:
x-goog-api-client
length is stable across 10 calls. if it grows, strip or rebuild the header each call.if you want I ca…