-
Notifications
You must be signed in to change notification settings - Fork 137
Description
Describe the bug
The openinference-instrumentation-google-genai
package throws an error "Other field types of parts are not supported yet" when processing image data attached to Google GenAI requests. This error occurs specifically in the _get_attributes_from_part
function at line 367 of the request attributes extractor, suggesting that the instrumentation library doesn't properly handle types.Part
objects created from base64 image data.
To Reproduce
import base64
import asyncio
from google import genai
from google.genai import types
from openinference.instrumentation.google_genai import GoogleGenAIInstrumentor
# Enable instrumentation (this is what causes the error)
GoogleGenAIInstrumentor().instrument()
async def reproduce_error():
client = genai.Client(api_key="your-api-key")
# Create a simple base64 image (1x1 pixel PNG)
base64_img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg=="
# Extract MIME type and decode base64 data
mime_type = base64_img.split(";")[0].replace("data:", "")
img_data = base64.b64decode(base64_img.split(",")[1])
# Create Part object from bytes (this is what triggers the error)
image_part = types.Part.from_bytes(
data=img_data,
mime_type=mime_type,
)
parts = ["Describe this image", image_part]
# This call will trigger the instrumentation error
response = await client.aio.models.generate_content(
model="gemini-2.5-flash",
contents=parts,
config=types.GenerateContentConfig(temperature=0.0),
)
return response
# Run the reproduction
asyncio.run(reproduce_error())
Expected behavior
The request should complete successfully without instrumentation errors. The OpenInference instrumentation should properly handle types.Part
objects created from both from_bytes()
and from_uri()
methods without throwing unsupported field type errors.
Error Details
{
"dt": "2025-09-11T11:52:33.622395+00:00",
"level": "error",
"severity": 4,
"message": "Other field types of parts are not supported yet",
"context": {
"runtime": {
"function": "_get_attributes_from_part",
"file": "../lib/python3.13/site-packages/openinference/instrumentation/google_genai/_request_attributes_extractor.py",
"line": 367,
"thread_id": 139450478468032,
"thread_name": "MainThread",
"logger_name": "openinference.instrumentation.google_genai._request_attributes_extractor"
}
}
}
Environment:
- OS: macOS (Darwin 24.6.0) (but also in prod with debian)
- Python: 3.13
- google-genai: 1.36.0
- openinference-instrumentation-google-genai: 0.1.5
Root Cause Analysis
The error suggests that the OpenInference instrumentation library's _get_attributes_from_part
function doesn't handle all possible types.Part
variations. Specifically, it appears to not support Part
objects created via types.Part.from_bytes()
method, which is commonly used for base64-encoded image data.
Related Issue
Previously encountered similar error: "Unexpected input contents type: <class 'PIL.JpegImagePlugin.JpegImageFile'>" when using PIL Image objects directly instead of types.Part.from_bytes()
. This was resolved by replacing PIL usage with types.Part.from_bytes()
in commit c476ea9d, but the instrumentation library still doesn't properly handle the resulting Part objects.
Additional context
- Error appears as:
ERROR:openinference.instrumentation.google_genai._request_attributes_extractor:Other field types of parts are not supported yet
- The error is non-blocking but creates noise in logs and monitoring
- Affects all image processing workflows using base64 image data
- API calls complete successfully despite the instrumentation error
Metadata
Metadata
Assignees
Labels
Type
Projects
Status