Document that setting attributes on a collection value is a programmer error - #504
Conversation
|
Thanks for this. I think setting attributes for an array or a dictionary should be a visible programmer error. We cannot express this as an API limitation unfortunately. What is the expected behavior for that intermediate log handler, would it rather propagate attributes inside containers? |
|
Fair enough, a programmer error works for me. My real complaint is that debug traps while release silently drops it, and the doc says “no-op”. If you want the assertion, I’ll rework this to keep it and fix the doc to say so. |
|
Reworked as doc-only: the assertion stays, the comment now calls it a programmer error and points at setting attributes on the leaf values instead. |
Motivation:
Logger.MetadataValue.attributesdocuments the setter as a no-op for.dictionaryand.array, but it callsassertionFailurethere. Debug builds trap, release builds do the documented no-op.Modifications:
Doc comment only. The assertion stays; the comment now says setting attributes on a collection value is a programmer error, that debug builds assert and release builds leave the value unchanged, and to set attributes on the leaf values instead.
Result:
The documentation matches the code. No behaviour change.
Found by an automated audit loop (Claude); patch and description reviewed by me.