Skip to content

fix: sanitize empty base64 image payloads for OpenAI requests#1417

Open
YanzheL wants to merge 2 commits intoWei-Shaw:mainfrom
YanzheL:fix/openai-empty-base64-image-payloads
Open

fix: sanitize empty base64 image payloads for OpenAI requests#1417
YanzheL wants to merge 2 commits intoWei-Shaw:mainfrom
YanzheL:fix/openai-empty-base64-image-payloads

Conversation

@YanzheL
Copy link
Copy Markdown
Contributor

@YanzheL YanzheL commented Mar 31, 2026

Summary

  • Skips empty or whitespace-only base64 image URLs in the Chat Completions compatibility translator before they are processed as input_image parts.
  • Sanitizes native OpenAI Responses payloads by removing empty base64 input_image entries from both nested message content and top-level input items.
  • Adds regression tests covering exact-empty, whitespace-only, nested, and top-level image payload cases while ensuring valid image inputs are preserved.

Testing

  • go test ./internal/pkg/apicompat
  • go test ./internal/service -run 'TestSanitizeEmptyBase64InputImagesInOpenAIRequestBodyMap|TestSanitizeEmptyBase64InputImagesInOpenAIBody|TestExtractOpenAIReasoningEffortFromBody|TestGetOpenAIRequestBodyMap_UsesContextCache|TestGetOpenAIRequestBodyMap_ParseErrorWithoutCache|TestGetOpenAIRequestBodyMap_WriteBackContextCache'
  • go build ./cmd/server

Closes #1011
Closes #1014

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.

能否支持GPT图片模型? gpt-5.4 图片不兼容吗?

1 participant