Skip to content

Conversation

@patrickthornton
Copy link
Contributor

Description

Refs: User request from @patrickthornton

When AsyncAPI messages are marked with contentType: application/octet-stream and payload: { type: string, format: binary }, the Python SDK now generates bytes type hints instead of str for WebSocket message parameters.

Changes Made

  • Added _is_binary_string() helper method to detect primitives with format: "binary" validation
  • Modified _get_type_hint_for_primitive() to return AST.TypeHint.bytes() for binary string primitives
  • Added version entry 4.46.7-rc3 to versions.yml

Testing

  • Unit tests added/updated (Note: Could not add a Fern definition test fixture because bytes is not supported as a WebSocket message body type in Fern definitions - the binary format is set when AsyncAPI is converted to Fern IR)
  • Manual code review completed

Human Review Checklist

  • Verify the _is_binary_string logic correctly accesses the PrimitiveType.v_2 union structure and validation format
  • Important: This change applies to ALL primitive type hints, not just WebSocket messages. Confirm this is the desired behavior and won't affect HTTP endpoints with binary payloads (which may have separate handling)
  • Verify the IR correctly preserves format: "binary" from AsyncAPI definitions

Link to Devin run: https://app.devin.ai/sessions/24b9fb2e623047f584bb06e66893c15b

When a WebSocket message payload has format: binary (from AsyncAPI
contentType: application/octet-stream with payload type: string,
format: binary), the Python SDK now generates bytes type hints
instead of str for the message parameter.

Co-Authored-By: patrick@buildwithfern.com <patrickthornton@college.harvard.edu>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: patrick@buildwithfern.com <patrickthornton@college.harvard.edu>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants