Skip to content

Conversation

@Mustafa-Esoofally
Copy link
Contributor

@Mustafa-Esoofally Mustafa-Esoofally commented Dec 25, 2025

Summary

Gemini file upload error for VertexAI

User sends: files=[File(...)]

_format_file_for_message(file) → returns Part

┌─────────────────────────────────────┐
│ BEFORE (Bug): │
│ formatted_messages.append(Part) │
│ Content(parts=[]) ← empty! │
├─────────────────────────────────────┤
│ AFTER (Fix): │
│ message_parts.append(Part) │
│ Content(parts=[Part]) ← correct! │
└─────────────────────────────────────┘

API call: contents=formatted_messages

Fixed: #5843

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Improvement
  • Model update
  • Other:

Checklist

  • Code complies with style guidelines
  • Ran format/validation scripts (./scripts/format.sh and ./scripts/validate.sh)
  • Self-review completed
  • Documentation updated (comments, docstrings)
  • Examples and guides: Relevant cookbook examples have been included or updated (if applicable)
  • Tested in clean environment
  • Tests added/updated (if applicable)
@Mustafa-Esoofally Mustafa-Esoofally requested a review from a team as a code owner December 25, 2025 05:18
final_message = Content(role=role, parts=message_parts)
formatted_messages.append(final_message)

if isinstance(file_content, GeminiFile):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code since _format_file_for_message always return part

file_content = self._format_file_for_message(file)
if isinstance(file_content, Part):
formatted_messages.append(file_content)
message_parts.append(file_content)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

file should be added as a Part

@Mustafa-Esoofally Mustafa-Esoofally changed the title Bug - gemini vertex ai file upload error Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants