Skip to content

fix(go): handle optional image encoding (*types.Image)#2996

Merged
hellovai merged 1 commit intocanaryfrom
fix/go-optional-image-encoding
Jan 17, 2026
Merged

fix(go): handle optional image encoding (*types.Image)#2996
hellovai merged 1 commit intocanaryfrom
fix/go-optional-image-encoding

Conversation

@hellovai
Copy link
Contributor

Summary

  • Fix Go encoder to handle pointer-to-interface types like *types.Image
  • In Go, *types.Image (pointer to interface) doesn't implement InternalBamlSerializer, but the dereferenced value does
  • Also fixes a bug where all media types were converted to Image in streaming type conversion

Test plan

  • All 115 type_gen tests pass across Go, Python, TypeScript, Rust
  • Manual verification of optional image encoding
  • Added Go integration tests TestOptionalImageInputNil and TestOptionalImageInputWithValue

🤖 Generated with Claude Code

Fix Go encoder to properly handle pointer-to-interface types like *types.Image.
In Go, a pointer to an interface doesn't implement the interface, so we need
to check both the original value and the dereferenced value for InternalBamlSerializer.

Also fixes a bug where all media types were being converted to Image in streaming
type conversion - now preserves the actual media type (Image, Audio, PDF, Video).

Changes:
- Add second type assertion check on concreteValue in encode.go
- Fix streaming.rs to preserve media types instead of converting all to Image
- Add media type tests to type_serialization_tests.md
- Add Go integration tests for optional image input

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
beps Ready Ready Preview, Comment Jan 17, 2026 5:38am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
promptfiddle Skipped Skipped Jan 17, 2026 5:38am

Request Review

@hellovai hellovai enabled auto-merge January 17, 2026 05:47
@hellovai hellovai added this pull request to the merge queue Jan 17, 2026
Merged via the queue into canary with commit d3d76dc Jan 17, 2026
50 checks passed
@hellovai hellovai deleted the fix/go-optional-image-encoding branch January 17, 2026 06:19
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.

1 participant