Repository navigation
Name the argument when the constructor is given a non-string - #35
Conversation
A truthy non-string base_url, application, version, key or install_id raised AttributeError from .strip() with no hint of which argument was wrong. They now raise a ValueError naming the argument and the type it got, never the value, so a rejected key does not reach a log. Falsy values keep their meaning: they never reached .strip(), so a program passing one already ran. Also wait for the sender to take the first report in test_a_dropped_report_is_logged_at_debug_with_its_name. If it woke after the last filler was dropped, the overflow event found a free slot and was queued, failing the test under load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Self-review rubric (head
Finding, corrected before posting: the first PR description said only values that already stopped the constructor change, and that was wrong. Not changed: a falsy non-string such as
No do-not-auto-merge path matches: This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener). drafted by Claude on behalf of Daniel Stephenson |
Summary
base_url,application,version,keyorinstall_idraised anAttributeErrorfrom.strip()that did not say which argument was wrong. AValueErroris now raised instead, such asversion must be a string, not float, so the rule that constructor errors name their argument holds for these values too.key=0never reached.strip()and keep their meaning, and a test pins that.bytes(and any other truthy non-string with a.strip()).bytesforapplication,version,keyorinstall_idbuilt a disabled client without complaint, andkey=b"k"built an enabled one, whose reports could not be sent because theAuthorizationheader is built by adding it to astr. Such a program now stops at startup with a named error, including when reporting is off. That is accepted here because the same value would lose every report once reporting was on, and it matches the fix A non-string constructor argument raises an AttributeError that does not name the argument #33 suggests.test_a_dropped_report_is_logged_at_debug_with_its_nameis made deterministic. It failed in 2 of 7 full-suite runs on unmodifiedmain, so it could have failed this PR at random. The wait is the onetest_close_on_a_full_queue_drops_the_oldest_report_and_still_stops_the_senderalready uses.Closes #33
Closes #34
Test plan
python3 -m unitteston Python 3.8.10: 72 tests, OK, in 6 consecutive full-suite runs (69 tests before this change)trace_client/trace_client.pystashed,test_a_value_that_is_not_a_string_is_rejected_by_the_argument_it_was_given_forandtest_a_rejected_key_is_not_repeated_in_the_errorerrored withAttributeError: 'int' object has no attribute 'strip'; with it restored, both passedtest_an_empty_value_of_another_type_keeps_its_old_meaningpassed with the fix stashed and with it restored, as it characterizes behaviour that must not changeoverflow-event, the original test failed with1 != 0 : a drop names the event it dropped: ['[trace] queue full, dropped filler'], and the rewritten test passed. The harness was a scratch file and is not committedtest (3.8),test (3.10)andtest (3.12)green on the PR head (70caea5, run 42338761845)Trace server and Java
No Java-visible behavior changed: nothing on the wire changes, and neither the opt-out values nor the
disabled_reasonstrings are touched. This gap comes from Python's dynamic typing, so a counterpart in trace-client-java is not expected, but that source could not be read from this session and the point is unverified.Issues not picked
_send, which is wire format held for owner review, and it deserves its own PR.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