feat(errors): add redacted typed transport failures - #23
Open
Jason-Morcos wants to merge 1 commit into
Open
Conversation
Contributor
Author
|
@codex review |
Jason-Morcos
force-pushed
the
codex/py-02-typed-errors
branch
from
August 2, 2026 23:33
3039bfc to
796ca39
Compare
Contributor
Author
|
Adversarial follow-up complete for exact head Validation: 66 passed on Python 3.14 / OpenSSL 3.6.3; 27 focused error tests passed; build/import, Ruff, diff, and introduced-content safety checks passed. @codex review |
Jason-Morcos
force-pushed
the
codex/py-02-typed-errors
branch
from
August 3, 2026 19:46
796ca39 to
c7e15a7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The library currently reports protocol failures through broad built-ins such as
ConnectionError,TimeoutError, andValueError. Callers cannot reliably distinguish a closed session from a handshake failure, malformed CoAP, a bounded Blockwise abort, or a probe backend failure without parsing strings.Several of those strings also interpolate remote endpoints, resource paths, or raw OpenSSL text. That makes normal exception reporting unsuitable for secret-safe diagnostics.
Public API added
smartthings_local.errorsnow provides a documented hierarchy rooted atSmartThingsLocalError:Each concrete error has a stable
code, a fixed redacted message, and a deterministicrepr. Arbitrary detail cannot be passed to the constructor. The existing session, probe, and CoAP boundaries now emit the appropriate concrete types where they already fail today.OpenSSL handshake failures discard the raw exception context and chain only from a fixed
DTLS backend failedmarker, so raw backend text is retained in neither exception linkage nor the formatted traceback.Backward compatibility
Every mapped error still subclasses the built-in callers previously caught:
ConnectionErrorfor session/probe/authentication/Blockwise/Observe errorsTimeoutErrorfor bounded session timeoutsValueErrorfor malformed CoAPOSErrorfor endpoint errorsPermissionErrorfor authorization errorsConstructor argument validation remains
ValueError.Scope
This PR does not change socket behavior, endpoint selection, retry policy, authentication policy, CoAP response handling, or Observe lifecycle. The unused taxonomy members establish names for those later contracts without implementing them here. It is independent of #21 and #22.
Validation
81 passed45 passedsmartthings_local/errors.pyThe LibreSSL compatibility fix from #22 is now included in upstream
main; this branch is rebased on that fix and the merged validation workflow from #21.