TraceClient.report() promises it never raises, but a non-string name escapes the try block.
In trace_client/trace_client.py, report() evaluates not name or not name.strip() on the line before its try. Passing a truthy value that is not a str, for example report(123), raises AttributeError: 'int' object has no attribute 'strip' straight into the host program. Reproduced on Python 3.8.10:
>>> c = TraceClient("http://127.0.0.1:1", "app", key="k")
>>> c.report(123)
AttributeError: 'int' object has no attribute 'strip'
The class docstring and the README's "What report promises" table both say report never raises. The type hint says str, but annotations are not enforced, and this is exactly the case the promise exists for.
Suggested fix: run the blank-name check inside the existing try, so a bad name gets dropped and logged at DEBUG the same way any other unqueueable report is.
This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson
TraceClient.report()promises it never raises, but a non-stringnameescapes thetryblock.In
trace_client/trace_client.py,report()evaluatesnot name or not name.strip()on the line before itstry. Passing a truthy value that is not astr, for examplereport(123), raisesAttributeError: 'int' object has no attribute 'strip'straight into the host program. Reproduced on Python 3.8.10:The class docstring and the README's "What
reportpromises" table both sayreportnever raises. The type hint saysstr, but annotations are not enforced, and this is exactly the case the promise exists for.Suggested fix: run the blank-name check inside the existing
try, so a bad name gets dropped and logged at DEBUG the same way any other unqueueable report is.This issue was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson