Skip to content

[BUG CLIENT]: Attribute error raised when trying to httpx content in otel.py module #347

@panagiotisrit

Description

@panagiotisrit

Python -VV

Python 3.12.8 (main, Jul 24 2025, 15:51:39) [Clang 16.0.0 (clang-1600.0.26.6)]

Pip Freeze

annotated-types==0.7.0
anyio==4.11.0
asttokens==3.0.0
backoff==2.2.1
beautifulsoup4==4.14.3
certifi==2025.8.3
cfgv==3.4.0
charset-normalizer==3.4.4
click==8.3.0
cobble==0.1.4
coverage==7.10.7
decorator==5.2.1
distlib==0.4.0
distro==1.9.0
docstring-parser-fork==0.0.14
dynaconf==3.2.11
eval-type-backport==0.3.1
executing==2.2.1
fastapi==0.117.1
filelock==3.19.1
googleapis-common-protos==1.72.0
h11==0.16.0
httpcore==1.0.9
httpx==0.28.1
identify==2.6.14
idna==3.10
importlib-metadata==8.7.1
iniconfig==2.1.0
invoke==2.2.1
ipython==9.5.0
ipython-pygments-lexers==1.1.1
jedi==0.19.2
jiter==0.13.0
langfuse==3.13.0
librt==0.7.7
mammoth==1.11.0
markdownify==0.14.1
matplotlib-inline==0.1.7
mistralai==1.12.0
mypy==1.19.1
mypy-extensions==1.1.0
nodeenv==1.9.1
openai==2.17.0
opentelemetry-api==1.38.0
opentelemetry-exporter-otlp-proto-common==1.38.0
opentelemetry-exporter-otlp-proto-http==1.38.0
opentelemetry-proto==1.38.0
opentelemetry-sdk==1.38.0
opentelemetry-semantic-conventions==0.59b0
packaging==25.0
parso==0.8.5
pathspec==1.0.2
pexpect==4.9.0
pip==25.3
platformdirs==4.4.0
pluggy==1.6.0
pre-commit==4.3.0
prompt-toolkit==3.0.52
protobuf==6.33.4
ptyprocess==0.7.0
pure-eval==0.2.3
pydantic==2.11.9
pydantic-core==2.33.2
pydoclint==0.8.3
pygments==2.19.2
pytest==8.4.2
pytest-asyncio==1.3.0
pytest-cov==7.0.0
python-dateutil==2.9.0.post0
python-multipart==0.0.21
pyyaml==6.0.2
requests==2.32.5
ruff==0.13.1
six==1.17.0
sniffio==1.3.1
soupsieve==2.8.1
stack-data==0.6.3
starlette==0.46.2
structlog==24.4.0
tenacity==9.1.2
tqdm==4.67.3
traitlets==5.14.3
typing-extensions==4.15.0
typing-inspection==0.4.1
unoserver==3.6
urllib3==2.6.3
uv==0.9.11
uvicorn==0.37.0
virtualenv==20.34.0
wcwidth==0.2.14
wrapt==1.17.3
zipp==3.23.0

Reproduction Steps

from mistralai import Mistral

Use provided client

    mistral_client =  Mistral(api_key=settings.mistral_api_key)

    # Upload file
    uploaded = await mistral_client.files.upload_async(
        file={"file_name": file_input.filename, "content": file_input.content},
        purpose="ocr",
    )

    # inside parse_pdf_to_markdown
    with langfuse.start_as_current_observation(name="mistral_ocr", as_type="tool", metadata={
        "model": settings.mistral_model,
    }) as tool:

        # Get signed URL
        signed_url = await mistral_client.files.get_signed_url_async(file_id=uploaded.id)

        # Process with OCR
        response = await mistral_client.ocr.process_async(
            model=settings.mistral_model,
            document={"type": "document_url", "document_url": signed_url.url},
            include_image_base64=False,
            image_limit=0,
        )

Expected Behavior

mistral's otel implementation enrich_span_from_request is trying to access request._content, but httpx's Request object at 0.28.1 does not contain such an object, therefore throwing an attribute error.

Here's the error:
Failed to create span for request. Traceback (most recent call last):
File "/Users/user/Documents/Repos/my-repo/.venv/lib/python3.12/site-packages/mistralai/extra/observability/otel.py", line 250, in get_traced_request_and_span
span = enrich_span_from_request(span, request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/Documents/Repos/my-repo/.venv/lib/python3.12/site-packages/mistralai/extra/observability/otel.py", line 94, in enrich_span_from_request
if request._content:
^^^^^^^^^^^^^^^^
AttributeError: 'Request' object has no attribute '_content'. Did you mean: 'content'?

Otel.py was introduced on tag 1.10.0.

Additional Context

No response

Suggested Solutions

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions