Skip to content

fix(api): percent-encode non-ASCII bytes in X-Author-Identity header#1409

Merged
svarlamov merged 3 commits into
mainfrom
fix/api-client-utf-8-escape-headers
May 21, 2026
Merged

fix(api): percent-encode non-ASCII bytes in X-Author-Identity header#1409
svarlamov merged 3 commits into
mainfrom
fix/api-client-utf-8-escape-headers

Conversation

@svarlamov
Copy link
Copy Markdown
Member

@svarlamov svarlamov commented May 20, 2026

Summary

  • Git author names with non-ASCII UTF-8 characters (e.g. "Exöutf8lastname") caused ureq to reject the X-Author-Identity header, blocking all API calls including metrics uploads
  • Added a hand-rolled percent-encoding function that encodes non-ASCII bytes as %XX at storage time in resolve_git_identity()
  • Added hostname fallback: if git identity is unavailable, falls back to system hostname (COMPUTERNAME on Windows, HOSTNAME env var, or hostname command) so the header is still populated
  • The server can recover the original identity with standard percent-decoding; no data loss

Test plan

  • Unit tests covering ASCII passthrough, non-ASCII encoding, percent-sign reversibility, and ureq validity assertion
  • Manual verification: set git config user.name to a name with non-ASCII chars and run git ai flush-metrics-db
  • Manual verification: unset git user.name/email and confirm hostname is sent instead

🤖 Generated with Claude Code

Git author names containing non-ASCII UTF-8 characters (e.g. "ö")
caused ureq to reject the header value, preventing all API calls
including metrics uploads. Encode non-printable-ASCII bytes as %XX
sequences at storage time so the header is always valid.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

svarlamov and others added 2 commits May 20, 2026 23:19
If `git var GIT_COMMITTER_IDENT` fails or returns no name/email,
resolve_git_identity now falls back to the system hostname so the
X-Author-Identity header is still populated. Cross-platform: checks
COMPUTERNAME (Windows), HOSTNAME, then runs the `hostname` command.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Match git's own fallback format: "Username <username@hostname>"
instead of bare hostname. Uses USER/USERNAME env var for the name
and HOSTNAME/COMPUTERNAME/`hostname` command for the host part.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@svarlamov svarlamov merged commit db4e221 into main May 21, 2026
21 of 23 checks passed
@svarlamov svarlamov deleted the fix/api-client-utf-8-escape-headers branch May 21, 2026 03:38
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.

1 participant