Skip to content

toon: decode raises ValueError where the contract is ToonDecodeError #198

Closed

Description

@clementine-oaklight

What

Nine decode conformance cases raise ValueError where the module's contract is ToonDecodeError:

decode/validation-errors[4]   raised ValueError (want ToonDecodeError)
decode/validation-errors[5]   raised ValueError
decode/validation-errors[6]   raised ValueError
decode/validation-errors[80]  raised ValueError
decode/validation-errors[87]  raised ValueError
decode/validation-errors[94]  raised ValueError
decode/validation-errors[95]  raised ValueError
decode/validation-errors[96]  raised ValueError
decode/validation-errors[101] raised ValueError

The cases are malformed input that decode() should reject, so raising is right — but with the wrong type. A caller writing except ToonDecodeError (which is what the module's own docstring and Raises: sections promise) does not catch these; they escape as a bare ValueError.

Found while reconciling numbers for #195: the conformance gate requires ToonDecodeError specifically on the 158 shouldError decode cases, which is the stricter and correct reading. Under that rule the module is at 225/404 on decode, not 234/404 — my earlier figure on #184 accepted any exception. All nine are currently inside toon/conformance_baseline.json, so the gate tolerates them; that is the ratchet working as designed, not an endorsement.

Fix

Make the decode paths that raise bare ValueError raise ToonDecodeError instead — likely the same places that treat validation failures as generic value errors. Then shrink the baseline by those nine IDs, which is the mechanism #195 provides.

Worth doing while the module's version is already moving for the spec work, since it is an API-visible contract rather than a spec gap.

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions