Skip to content

fix(provider-utils): RFC 9110 compliant User-Agent header format#12945

Open
giulio-leone wants to merge 1 commit intovercel:mainfrom
giulio-leone:fix/user-agent-rfc-compliance
Open

fix(provider-utils): RFC 9110 compliant User-Agent header format#12945
giulio-leone wants to merge 1 commit intovercel:mainfrom
giulio-leone:fix/user-agent-rfc-compliance

Conversation

@giulio-leone
Copy link

Summary

Fixes #12799

The generated User-Agent header contained invalid product tokens per RFC 9110 §10.1.5, causing Azure OpenAI to reject all requests with HTTP 400 when running on Bun.

Root Cause

Two violations:

  1. ai-sdk/provider-utils/4.0.15 — The product name ai-sdk/provider-utils contains a /, which is only allowed as the separator between product name and version. This makes provider-utils/4.0.15 parse as an invalid product-version.

  2. runtime/bun/1.3.9 — Bun exposes navigator.userAgent = 'Bun/1.3.9'. Wrapping in runtime/${...} produces runtime/bun/1.3.9 with a nested / in the product-version.

RFC 9110 defines:

product = token "/" product-version
token = 1*tchar

Changes

  • get-runtime-environment-user-agent.ts: Parse navigator.userAgent to split product/version (e.g. Bun/1.3.9runtime-bun/1.3.9). Also fix Node.js path from runtime/node.js/ to runtime-node/.
  • post-to-api.ts + get-from-api.ts: Changed ai-sdk/provider-utils/ai-sdk-provider-utils/ (replace / with - in product name).
  • Updated test expectations to match new format.

Before / After

Before (invalid) After (RFC 9110 compliant)
ai-sdk/provider-utils/4.0.15 ai-sdk-provider-utils/4.0.15
runtime/bun/1.3.9 runtime-bun/1.3.9
runtime/node.js/v22.0.0 runtime-node/v22.0.0

@tigent tigent bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/azure provider/openai-compatible labels Feb 28, 2026
@giulio-leone giulio-leone force-pushed the fix/user-agent-rfc-compliance branch 2 times, most recently from 92c3ff2 to 93445f7 Compare February 28, 2026 14:49
@giulio-leone
Copy link
Author

Intervention note for this PR:

Current blocker appears to be Vercel deployment authorization, not code/test correctness.

Observed pattern:

  • Vercel check fails with: "Authorization required to deploy."
  • Other checks (e.g., Socket Security / Vercel Agent Review) are passing.

Recommended unblock sequence:

  1. Complete the Vercel Git authorization flow from the failing check link.
  2. Re-run checks on this PR.
  3. If Vercel passes, this PR should move forward with normal review.

If useful, I can follow up with a PR-by-PR status sweep after authorization is completed.

@giulio-leone
Copy link
Author

This PR is ready for review — all CI checks pass, no merge conflicts, and all review threads have been resolved. Ready to merge when approved. 🚀

The generated User-Agent header contained invalid product tokens per
RFC 9110 §10.1.5:
- ai-sdk/provider-utils/4.0.15: slash in product name
- runtime/bun/1.3.9: nested slash in product-version (from Bun UA)

Now produces RFC-compliant tokens:
- ai-sdk-provider-utils/4.0.15
- runtime-bun/1.3.9

Fixes vercel#12799
@giulio-leone giulio-leone force-pushed the fix/user-agent-rfc-compliance branch from 93445f7 to ab92248 Compare March 5, 2026 20:43
@giulio-leone
Copy link
Author

Hi! Gentle ping — this PR is rebased on main, CI passes, and ready for review. Happy to address any feedback. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/azure provider/openai-compatible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(provider-utils): invalid User-Agent header format causes 400 errors with Azure OpenAI when using Bun

1 participant