Remove dead domain codec helpers and tighten certhash decoding#103
Merged
Remove dead domain codec helpers and tighten certhash decoding#103
Conversation
Remove unused module-level domain codec helpers from issue #100, enforce base64url certhash input normalization for stable type/test behavior, and add a linux-docs Make target alias for CI-style docs checks. Made-with: Cursor
Contributor
Author
|
@yashksaini-coder can you review ? |
…e-domain-dead-code Made-with: Cursor # Conflicts: # multiaddr/codecs/certhash.py
acul71
commented
Mar 17, 2026
Contributor
Author
acul71
left a comment
There was a problem hiding this comment.
cast(bytes, ...) was used for type-checking, not runtime behavior.
multibase.decode(string)is not precisely typed (oftenAnyor a broad type in stubs).- The code then passes that value to
self.validate(...), which expectsbytes. - Static analyzers (
mypy/pyrefly) may complain: “this might not bebytes.” cast(bytes, x)tells the type checker: “treatxas bytes here.”
Important: cast does not convert anything at runtime.
So this line:
decoded_bytes = cast(bytes, multibase.decode(string))only silences type errors; it does not protect against decode() returning the wrong shape/type.
That is why your current approach is stronger: it does real runtime normalization/checking and then guarantees bytes before validation.
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.
Summary
to_bytes/to_stringfunctions frommultiaddr.codecs.domain(issue Minor Bug: Dead Code in domain.py Module #100)newsfragments/100.removal.rstdocumenting the removalcerthashmultibase decode output and enforceu(base64url) prefix to keep typing and protocol validation consistentTest plan
source venv/bin/activate && make prsource venv/bin/activate && make docs-ciCloses #100