Skip to content

fix: raise UnknownHashTypeException in HashTypeFactory.from_composite_str - #1092

Closed
RajGahoi wants to merge 1 commit into
CycloneDX:mainfrom
RajGahoi:fix/from-composite-str-unknown-hash
Closed

RajGahoi wants to merge 1 commit into
CycloneDX:mainfrom
RajGahoi:fix/from-composite-str-unknown-hash

Conversation

@RajGahoi

@RajGahoi RajGahoi commented Dec 2, 2026 •

Copy link
Copy Markdown

Summary

  • Updated HashTypeFactory.from_composite_str() in cyclonedx/contrib/hash/factories.py to:
    • Raise UnknownHashTypeException when composite_hash has no : separator (instead of IndexError).
    • Use getattr(HashAlgorithm, ..., None) and check isinstance(alg, HashAlgorithm) so unsupported sha*, sha3*, and blake2* prefixes (e.g. blake2b_256, sha224, sha3-224) raise UnknownHashTypeException instead of AttributeError.
  • Expanded test_hash_type_from_composite_str_throws_on_unknown in tests/test_model.py to cover blake2b_256, sha224, sha3-224, and missing :.

Testing

  • python -m py_compile cyclonedx/contrib/hash/factories.py tests/test_model.py passed (pytest could not collect locally because py_serializable is not installed in the Windows Python environment; CI will run the full test suite).

@RajGahoi
RajGahoi requested a review from a team as a code owner December 2, 2026 21:12
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jkowalleck

jkowalleck commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

You missed filling the pull request template.
Probably for the reason that your AI agent just is not aware of this thing.

Anyway, will not accept this solution.
The respective ticket #1075
is marked as "good first issue" - it is meant for people that want to get involved in the project, its docs and code base.
This ticket is not meant as a low-hanging fruit for AI agents.

@jkowalleck jkowalleck closed this Dec 3, 2026
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.

HashTypeFactory.from_composite_str() raises AttributeError / IndexError instead of UnknownHashTypeException

2 participants