Skip to content

Say MAX_TAG_LENGTH bounds the install ID too; close leaked test clients - #14

Merged
dmccoystephenson merged 1 commit into
mainfrom
trace/tag-length-comment-and-test-hygiene
Oct 13, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
trace/tag-length-comment-and-test-hygiene

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

  • MAX_TAG_LENGTH's #: comment now names both values the client sets and limits: the program version and the installation ID (install_id= and the lines install_id_from_file accepts). Only the comment changed; behaviour is the same. The README already gave both limits.
  • test_blank_install_id_is_none_and_an_overlong_one_is_rejected now closes the three enabled clients built in its loop, so their sender threads stop when the test ends. The assertion message also names which blank value failed.
  • test_a_disabled_client_never_makes_up_or_writes_an_install_id now sets DO_NOT_TRACK through mock.patch.dict(os.environ, ...), like the rest of the suite, instead of setting and deleting it on os.environ directly.

Closes #12
Closes #13

No bug fixes, so no regression tests were added. The test changes keep every existing assertion.

trace-client-java: nothing a Java user could see has changed (comment and test changes only). No matching change is needed.

Test plan

  • python3 -m compileall -q trace_client tests
  • python3 -m unittest: 45 tests run, OK (local interpreter)
  • CI Build matrix: test (3.8), test (3.10), test (3.12)

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

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

MAX_TAG_LENGTH's comment named only the program version, though it also
bounds install_id= and the ID lines install_id_from_file accepts.

In the tests, close the three enabled clients the blank-install-ID loop
left running, and set DO_NOT_TRACK through mock.patch.dict rather than
writing os.environ directly.

Closes #12
Closes #13

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

Copy link
Copy Markdown
Member Author

Self-review rubric (scored against CI run 38223873286 and gh pr diff 14):

  • Scope: PASS. Two files changed, 9 lines added and 7 removed. The comment change is MAX_TAG_LENGTH's comment says it bounds only the program version #12 and the two test changes are Two tests leave sender threads running or set os.environ directly #13. No unrelated formatting.
  • Tests-new: PASS (not applicable). No new public method, constant or name was added.
  • Tests-fix: PASS (not applicable). There is no production bug fix: the trace_client.py change is a comment only. No existing assertion was removed or weakened. The blank-ID loop only gained a repr(blank) message.
  • Sibling structure / sibling renames: PASS (not applicable). No new files and no renames.
  • Docs: PASS. README "Every event carries a random installation ID" already says both the version and install_id= are limited to 255 characters, so the new comment now agrees with it. The README needs no change.
  • Issue resolution: PASS. MAX_TAG_LENGTH's comment says it bounds only the program version #12: the named comment was rewritten. Two tests leave sender threads running or set os.environ directly #13: both tests named in the issue changed as the issue suggested.
  • CI: PASS. test (3.8), test (3.10) and test (3.12) are all green on the PR head.
  • Stdlib-only: PASS. git diff origin/main -- trace_client tests | grep '^+.*import' returns nothing, and pyproject.toml is untouched.
  • Py3.8 floor: PASS. test (3.8) is green.
  • Never-raises / never-blocks: PASS (not applicable). No code path reachable from report(), _drain(), _send() or close() changed.
  • Log level: PASS. git diff origin/main | grep '^+.*_LOG\.' returns nothing.
  • Version agreement: PASS. No version string was touched, and all five places still read 0.4.1.
  • Exports: PASS (not applicable). No new public names.
  • Java parity noted: PASS. The PR body says nothing a Java user could see has changed.

Judgment call, left as is:

  • tests/test_trace_client.py:509-511: client.close() comes after the assertion. If the assertion ever failed, that one client would be left running. self.addCleanup(client.close) would also cover the failure case. The plain call was kept because it matches how the rest of the suite closes clients, where close() also follows the assertions.

Scope note: test_a_disabled_client_never_makes_up_or_writes_an_install_id now patches the environment only while by_environment is being built. That is enough, because disabled_reason is decided once, in the constructor.

Do-not-auto-merge check: no protected path is touched (no pyproject.toml, version string, wire format, opt-out values, workflow or LICENSE). Merging is still left to a human because this session has no merge authorization.

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


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 98ae482 into main Oct 13, 2026
3 checks passed
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.

Two tests leave sender threads running or set os.environ directly MAX_TAG_LENGTH's comment says it bounds only the program version

1 participant