Skip to content

fix(skills_hub): handle bytes content in bundle_content_hash - #13424

Closed
Linux2010 wants to merge 1 commit into
NousResearch:mainfrom
Linux2010:fix/skills-update-bytes-hash
Closed

Linux2010 wants to merge 1 commit into
NousResearch:mainfrom
Linux2010:fix/skills-update-bytes-hash

Conversation

@Linux2010

Copy link
Copy Markdown
Contributor

What broke

Running hermes skills update crashed with AttributeError: 'bytes' object has no attribute 'encode' when skill bundles contained binary files (e.g. audio assets from official skills like neutts).

Root cause

SkillBundle.files is defined as Dict[str, Union[str, bytes]], but bundle_content_hash() assumed all file content was str and called .encode("utf-8") on every value. When the value was already bytes, this caused a crash.

Traceback:

AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'?

Why this fix is minimal

Single function fix - detect type and route bytes directly to hash.update(), encode strings as before. No broader changes to:

  • SkillBundle class or file loading logic
  • Other hash computation functions
  • Quarantine/installation logic

Patch (4 lines added):

content = bundle.files[rel_path]
# files can contain str or bytes; handle both
if isinstance(content, bytes):
    h.update(content)
else:
    h.update(content.encode("utf-8"))

What I tested

Added regression test verifying:

  • bytes content is handled without crash
  • Hash computation is deterministic (same content = same hash)
  • Mixed str + bytes bundles work correctly

What I intentionally did not change

  • No changes to SkillBundle class definition
  • No changes to how files are downloaded or loaded
  • No changes to content_hash() in skills_guard.py
  • No changes to update checking or installation flow

Fixes #2739

What broke:
Running `hermes skills update` crashed with AttributeError: 'bytes'
object has no attribute 'encode' when skill bundles contained binary
files (e.g. audio assets from official skills).

Root cause:
SkillBundle.files is defined as Dict[str, Union[str, bytes]], but
bundle_content_hash() assumed all file content was str and called
.encode("utf-8") on every value. When the value was already bytes,
this caused a crash.

Why this fix is minimal:
Single function fix - detect type and route bytes directly to
hash.update(), encode strings as before. No broader changes to
SkillBundle, file handling, or any other hash computation paths.

What I tested:
Added regression test verifying bytes content is handled correctly
and produces deterministic hashes.

What I intentionally did not change:
- No changes to SkillBundle class or file loading logic
- No changes to other hash computation functions
- No changes to quarantine/installation logic
@teknium1

Copy link
Copy Markdown
Collaborator

Thanks for the contribution, @Linux2010!

Closing this as a duplicate of #2740 (by @Mibayy), which targets the same fix/feature. We're consolidating on that PR for review.

If you want to help push it over the line, please jump in there — or if you think your approach is better for a specific reason that isn't covered in the other PR, let us know and we can reopen.

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.

[Bug]: hermes skills update fails

2 participants