fix(shared): transliterate x-posthog-property header values to ASCII#3375
Conversation
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
The sanitizer kept latin-1 characters because undici accepts them, but the Claude Code CLI (Bun's fetch) rejects any non-ASCII header value. A task title like 'sono più di 48 ore…' forwarded through ANTHROPIC_CUSTOM_HEADERS made every request fail client-side, so the task died and retry hit the same wall. NFKD-decompose and strip combining marks so accents degrade to their base letters instead of vanishing, then drop anything left outside printable ASCII.
7022cdf to
b29e184
Compare
…through builder Trim the sanitizer doc to the load-bearing constraint (Bun rejects non-ASCII header values) and note the combining-mark pass only guards newline-run collapsing. Collapse duplicative transliteration test cases. Route the hand-built team_id header line in the Claude session builder through buildGatewayPropertyHeaders so every x-posthog-property-* header goes through the shared sanitizer.
…ssion class Cover the distinct transliteration classes (precomposed accents, pre-decomposed combining marks, NFKD compatibility forms, non-decomposable letters, fully non-Latin input) and add an invariant test asserting emitted values are always printable ASCII for a battery of hostile titles.
|
Reviews (1): Last reviewed commit: "test(shared): expand header sanitizer co..." | Re-trigger Greptile |
| .replace(/[\u0300-\u036f]/g, "") | ||
| .replace(/[\r\n]+/g, " ") | ||
| .replace(/[^\x20-\x7e]/g, ""); | ||
| } |
There was a problem hiding this comment.
When a property value is entirely non-Latin, such as a Japanese Slack task title, this strips the whole value and still emits an empty x-posthog-property-task_title header. If the LLM gateway captures that header as-is, AI generation events lose the task title and dashboards or filters see a blank value instead of the original title.
Problem
Slack-originated task runs fail whenever the task title contains an accented character (Zendesk ticket #62236, internal link):
Task metadata is forwarded to the LLM gateway as
x-posthog-property-*headers viaANTHROPIC_CUSTOM_HEADERS. The sanitizer kept latin-1 characters (fine for undici), but the Claude Code CLI is a Bun binary and Bun's fetch rejects any non-ASCII header value — so the request dies client-side andretryhits the same wall.Changes
sanitizeHeaderValuetransliterates accents to their ASCII base via NFKD (più→piu) and drops everything else outside printable ASCII — the only range every HTTP client accepts.team_idheader line in the Claude session builder now goes through the shared builder too.How did you test this?
pnpm vitest runinpackages/sharedand the llm-gateway tests inpackages/core— all pass.pnpm typecheckinpackages/sharedandpackages/agent.bun -e 'new Headers({"x": "più"})'.Automatic notifications
🤖 Generated with Claude Code