Skip to content

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

Closed

Description

@dmccoystephenson

An application name that a header cannot carry causes every event to be dropped, even though the JSON body could carry the name without trouble.

_send puts the application in the User-Agent header (trace_client/trace_client.py:311). http.client encodes header values as Latin-1 and refuses a bare line break, so urlopen raises before anything is sent. The failure is caught and logged at DEBUG, so report() stays quiet, the client still says enabled, and nothing ever reaches the server.

Reproduced on Python 3.8.10 against a loopback server:

application Result
MyGame delivered
Zürich delivered
ゲーム not delivered: 'latin-1' codec can't encode characters in position 27-29
emoji🎲 not delivered: 'latin-1' codec can't encode character
Line\nBreak not delivered: Invalid header value

The promise is that a failing server costs a report. A program's name should not cost all of them. test_non_ascii_names_and_tags_arrive_intact_as_utf8_json covers event names and tags but uses the ASCII application Spiel, so this path has no test.

Suggested fix: replace only the characters a header cannot carry with ? in the User-Agent. The body keeps the exact name, and names that are delivered today keep the header they send today.

A key outside Latin-1 fails the same way, but such a key cannot be valid, so no change is proposed for it.

This issue 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions