Skip to content

Remove dead domain codec helpers and tighten certhash decoding#103

Merged
acul71 merged 2 commits intomasterfrom
fix/issue-100-remove-domain-dead-code
Mar 17, 2026
Merged

Remove dead domain codec helpers and tighten certhash decoding#103
acul71 merged 2 commits intomasterfrom
fix/issue-100-remove-domain-dead-code

Conversation

@acul71
Copy link
Contributor

@acul71 acul71 commented Mar 15, 2026

Summary

  • remove unused module-level to_bytes/to_string functions from multiaddr.codecs.domain (issue Minor Bug: Dead Code in domain.py Module #100)
  • add newsfragments/100.removal.rst documenting the removal
  • normalize certhash multibase decode output and enforce u (base64url) prefix to keep typing and protocol validation consistent

Test plan

  • source venv/bin/activate && make pr
  • source venv/bin/activate && make docs-ci

Closes #100

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
@acul71
Copy link
Contributor Author

acul71 commented Mar 15, 2026

@yashksaini-coder can you review ?

@acul71 acul71 self-assigned this Mar 16, 2026
…e-domain-dead-code

Made-with: Cursor

# Conflicts:
#	multiaddr/codecs/certhash.py
Copy link
Contributor Author

@acul71 acul71 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cast(bytes, ...) was used for type-checking, not runtime behavior.

  • multibase.decode(string) is not precisely typed (often Any or a broad type in stubs).
  • The code then passes that value to self.validate(...), which expects bytes.
  • Static analyzers (mypy/pyrefly) may complain: “this might not be bytes.”
  • cast(bytes, x) tells the type checker: “treat x as 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.

@acul71 acul71 merged commit 5c4d651 into master Mar 17, 2026
17 checks passed
@acul71 acul71 deleted the fix/issue-100-remove-domain-dead-code branch March 17, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minor Bug: Dead Code in domain.py Module

1 participant