Skip to content

Keep an application name a header cannot carry out of the User-Agent - #32

Open
dmccoystephenson wants to merge 1 commit into
mainfrom
trace/application-name-in-user-agent
Open

dmccoystephenson wants to merge 1 commit into
mainfrom
trace/application-name-in-user-agent

Conversation

@dmccoystephenson

@dmccoystephenson dmccoystephenson commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Summary

  • An application name outside Latin-1, or one containing a line break, lost every event: http.client refused the User-Agent value and the failure was logged only at DEBUG. A new private helper, _user_agent, replaces any character outside printable Latin-1 with ? in that header.
  • application in the JSON body stays exact. Printable Latin-1 names keep the header they sent before, and Zürich is asserted to prove it.
  • The User-Agent shape and the ? rule are added to the README's wire format section, where the header was not documented.

Closes #30

Test plan

  • python -m unittest ran 69 tests, OK, on Python 3.8.10 (68 before this change)
  • New test test_an_application_name_a_header_cannot_carry_still_delivers_its_events covers Japanese, an emoji, a line break and a Latin-1 name
  • With the fix stashed, the new test failed with 1 != 0 : 'ゲーム' lost its event; with it restored, the suite passed
  • test (3.8), test (3.10) and test (3.12) green on the PR head

Trace server and Java

This is a header change in _send, which is on the dev loop's do-not-auto-merge list, so this PR is left for owner review. No body field changes. Two kinds of name see a different User-Agent: names that previously sent nothing now send one, and names holding a tab or other control character, which http.client let through, now show ? for it. Printable Latin-1 names are unaffected.

Whether trace-client-java needs the same change is not verified: its source could not be read from this session. Its README does not describe the User-Agent.

Issues not picked

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

🤖 Generated with Claude Code

http.client refuses a header outside Latin-1 or with a bare line break, so a
program named outside that range lost every event at DEBUG. Those characters
become ? in the header; the JSON body keeps the exact name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (head 5aaef56). This is the same session that wrote the change, so it is not an independent review.

  • Scope: PASS — three files changed, all for An application name outside Latin-1 loses every event to the User-Agent header #30; 33 insertions, 2 deletions.
  • Tests-new: PASS — no public name added; _user_agent is exercised through report() by the new test.
  • Tests-fix: PASS — with trace_client/trace_client.py stashed, the new test failed with 1 != 0 : 'ゲーム' lost its event; after git stash pop, 69 tests ran OK.
  • Sibling structure: PASS — no new files; the helper sits with the other module-level private functions and the regex beside _INSTALL_ID_LINE.
  • Sibling renames: PASS — nothing renamed.
  • Docs: PASS — the README wire format section now states the User-Agent shape and the ? rule; no other Phase 7 row is affected.
  • Issue resolution: PASS — the User-Agent line named in An application name outside Latin-1 loses every event to the User-Agent header #30 is changed. A key outside Latin-1 remains unchanged, as An application name outside Latin-1 loses every event to the User-Agent header #30 states.
  • CI: PASS — test (3.8), test (3.10) and test (3.12) passed on run 41830852296.
  • Stdlib-only: PASS — no import added to trace_client/; the test import is from the package itself; pyproject.toml untouched.
  • Py3.8 floor: PASS — test (3.8) green on the PR head.
  • Never-raises / never-blocks: PASS — _user_agent is called inside the existing try in _send; no blocking call added.
  • Log level: PASS — no _LOG call added.
  • Version agreement: PASS — no version string changed.
  • Exports: PASS — no public name added.
  • Java parity noted: FAIL — the PR body says parity is not verified, because the Java source could not be read from this session. This cannot be fixed mechanically and is left for the owner.

Findings:

  • trace_client/trace_client.py:333 — the docstring says a header carries "printable Latin-1 and nothing else". That describes what the client now sends, not what http.client enforces: a tab or other control character passed through before and now shows as ?. This is a small change for such names and was left in on purpose, since a cleaner header is the safer default. The PR body originally claimed no deliverable name changed; that claim was corrected.
  • Not covered: CI runs on ubuntu-latest and ubuntu-22.04 only, and nothing exercises Pyodide, where the README tells programs to build the client disabled anyway.

Merge hold: this PR changes a header in _send, which is on the loop's do-not-auto-merge list, so it has not been merged despite green CI.

This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

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.

An application name outside Latin-1 loses every event to the User-Agent header

1 participant