Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CDF-23957] 🧐 Robustify hash calculation #1439

Merged
merged 4 commits into from
Feb 5, 2025

Conversation

doctrino
Copy link
Collaborator

@doctrino doctrino commented Feb 5, 2025

Description

Please describe the change you have made.

Checklist

  • Prefixed the PR title with the Jira issue number on the form [CDF-12345].
  • Tests added/updated.
  • Run Demo Job Locally.
  • Documentation updated.
  • Changelogs updated in CHANGELOG.cdf-tk.md.
  • Template changelogs updated in CHANGELOG.templates.md.

if isinstance(content, str):
byte_content = content.encode("utf-8")
else:
byte_content = content.read_bytes()
Copy link
Collaborator Author

@doctrino doctrino Feb 5, 2025

Choose a reason for hiding this comment

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

It is much safer to just hash the bytes directly and not care about the encoding of the file only the hash. Encoding can lead to UnicodeDecodeError

Copy link

github-actions bot commented Feb 5, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
15779 11463 73% 60% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
cognite_toolkit/_cdf_tk/commands/build.py 79% 🟢
cognite_toolkit/_cdf_tk/utils/hashing.py 95% 🟢
TOTAL 87% 🟢

updated for commit: 99d3ac3 by action🐍

@doctrino doctrino merged commit ea5869d into main Feb 5, 2025
10 checks passed
@doctrino doctrino deleted the hashing-unicodedecodeerror branch February 5, 2025 07:45
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.

2 participants