Skip to content

fix(agent): encode non-ascii gateway property headers#3041

Open
MarxWellB wants to merge 1 commit into
PostHog:mainfrom
MarxWellB:fix/non-ascii-gateway-headers
Open

fix(agent): encode non-ascii gateway property headers#3041
MarxWellB wants to merge 1 commit into
PostHog:mainfrom
MarxWellB:fix/non-ascii-gateway-headers

Conversation

@MarxWellB

Copy link
Copy Markdown

Problem

Slack-created PostHog Code tasks can fail when the task title contains non-ASCII characters. The original task title is forwarded as an x-posthog-property-task_title HTTP header value, and some HTTP clients reject header values containing characters outside the safe ASCII range.

The original title should remain unchanged for storage and UI display. The unsafe boundary is only when the title is serialized into gateway property headers.

Fixes PostHog/posthog#65950.

Changes

  • Preserve the existing newline-collapsing behavior to prevent header injection.
  • Keep printable ASCII characters unchanged.
  • Percent-encode all non-ASCII characters with encodeURIComponent.
  • Add regression coverage for smart quotes, emoji, accented characters, CJK characters, and the Danish-style input described in the issue.

Why encode instead of strip?

Stripping non-ASCII characters makes the header safe, but loses user context. Encoding keeps the value ASCII-safe while preserving the original information in a reversible representation.

Examples:

å  -> %C3%A5
é  -> %C3%A9
東京 -> %E6%9D%B1%E4%BA%AC
🚀 -> %F0%9F%9A%80

How did you test this?

  • pnpm --filter @posthog/agent test gateway.test.ts
  • pnpm --filter @posthog/agent typecheck — fails locally due unresolved internal workspace packages such as @posthog/shared, @posthog/git, and @posthog/enricher; no errors are reported in gateway.ts or gateway.test.ts.

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix(agent): encode non-ascii gateway pro..." | Re-trigger Greptile

Comment thread packages/agent/src/utils/gateway.test.ts Outdated
@MarxWellB MarxWellB force-pushed the fix/non-ascii-gateway-headers branch 2 times, most recently from 770af36 to 1375a41 Compare July 1, 2026 01:41
@MarxWellB MarxWellB force-pushed the fix/non-ascii-gateway-headers branch from 1375a41 to 82ec8b2 Compare July 1, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug report: posthog code - non-ascii slack task titles break header

1 participant