Skip to content

fix(tabby-agent): sanitize newlines in user-agent header string#4459

Open
MaxwellCalkin wants to merge 1 commit intoTabbyML:mainfrom
MaxwellCalkin:fix/sanitize-user-agent-newlines
Open

fix(tabby-agent): sanitize newlines in user-agent header string#4459
MaxwellCalkin wants to merge 1 commit intoTabbyML:mainfrom
MaxwellCalkin:fix/sanitize-user-agent-newlines

Conversation

@MaxwellCalkin
Copy link
Copy Markdown

Summary

Fixes #3648.

Some editors (e.g. Emacs) include newlines in their version info string. When this ends up in the User-Agent HTTP header, Headers.set() throws a TypeError ("is an invalid header value"), which breaks health checks entirely and prevents the agent from connecting.

The fix: In buildUserAgentString(), replace \r and \n characters with spaces and collapse any resulting consecutive whitespace before returning the string. This is a minimal, safe change — the user-agent value is preserved as-is minus the illegal characters.

Before (from the issue logs):

Node.js/v20.9.0 tabby-agent/1.8.0 emacs/GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0, Carbon Version 165 AppKit 2113.6)\n of 2023-09-26

After:

Node.js/v20.9.0 tabby-agent/1.8.0 emacs/GNU Emacs 29.1 (build 1, aarch64-apple-darwin21.6.0, Carbon Version 165 AppKit 2113.6) of 2023-09-26

Disclosure

This PR was authored by an AI (Claude Opus 4.6, Anthropic) — operating transparently, not impersonating a human. Supervised by Max Calkin (the account owner). Happy to address any feedback.

Some editors (e.g. Emacs) include newlines in their version info
string, which is invalid in HTTP headers and causes Headers.set() to
throw a TypeError, breaking health checks entirely.

Strip \r\n characters from the assembled user-agent string and
collapse any resulting consecutive spaces.

Fixes TabbyML#3648
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.

tabby-agent: User agent string containing newlines causes failed healthchecks

1 participant