Skip to content

Bug fixs: Coerce str back to bytes for bytes-typed HookToolset parameters#70433

Open
ColtenOuO wants to merge 1 commit into
apache:mainfrom
ColtenOuO:fix-hooktoolset-bytes-coercion
Open

Bug fixs: Coerce str back to bytes for bytes-typed HookToolset parameters#70433
ColtenOuO wants to merge 1 commit into
apache:mainfrom
ColtenOuO:fix-hooktoolset-bytes-coercion

Conversation

@ColtenOuO

Copy link
Copy Markdown
Contributor

Summary

HookToolset advertises a hook method's bytes-typed parameters to the LLM as JSON strings (_TYPE_MAP maps bytes -> {"type": "string"}, since JSON has no binary type), but call_tool never converted the string back to bytes before calling the method. A hook method like S3Hook.load_bytes(bytes_data: bytes, ...) would receive a plain str, failing at runtime with an opaque TypeError: a bytes-like object is required, not 'str' from BytesIO.

Changes

  • Add _bytes_param_names(method) to resolve which parameters (including Optional[bytes]/bytes | None) are bytes-typed.
  • call_tool now UTF-8-encodes any str value supplied for those parameters before dispatching to the hook method.

Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Sonnet 5)

HookToolset advertises bytes parameters to the LLM as JSON strings
(there's no bytes type in JSON), but call_tool never converted them
back before invoking the hook method. A method like S3Hook.load_bytes
would receive a str where bytes is required, failing at runtime with
an opaque TypeError from BytesIO.
@ColtenOuO ColtenOuO changed the title Fix Bugs: Coerce str back to bytes for bytes-typed HookToolset parameters Bug fixs: Coerce str back to bytes for bytes-typed HookToolset parameters Jul 25, 2026
@ColtenOuO

Copy link
Copy Markdown
Contributor Author

It looks like the CI needs to be restarted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant