Skip to content

Python modules in /agents/python/ clobbering application dependencies (e.g. typing_extensions) #2685

@hamiltonkibbe

Description

@hamiltonkibbe

Bug Report

  • At what date and time did you most recently experience the problem?

2025-10-22 ~10AM ET

  • Where did you experience the problem? E.g. Azure Web Apps, Azure Functions, Azure Container Registry, or offline use.

Azure Web Apps

  • If your repo is publicly available please share its URL:

N/A

  • What happened?

My FastAPI application on python 3.13 failed to start

  • What did you expect or want to happen?

At startup FastAPI imports pydantic, which ultimately imports stuff from typing_extensions, and then ultimately launches a server that handles HTTP traffic.

I expected this all to succeed but it failed because there is a file named typing_extensions.py in /agents/python/ that is earlier in PYTHONPATH than the site-packages directory for the venv where the "real" typing_extensions module lives, as a result of this

  • How can we reproduce it?

Run a "boilerplate" py13 fastapi app on linux webapp

The minimum viable reproduction would be something like this:

# requirements.txt
fastapi
uvicorn
# main.py
from fastapi import FastAPI
app = FastAPI()

if __name__ == "__main__":
    import uvicorn
    uvicorn.run(app, host="0.0.0.0", port=8000)
  • Do you have log output? Please include between the backticks:
025-10-22T15:19:10.223535221Z  Updated PYTHONPATH to '/agents/python:/opt/startup/app_logs:/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages:/agents/python:/opt/startup/app_logs:/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages'
2025-10-22T15:19:14.020228603Z  Traceback (most recent call last):
2025-10-22T15:19:14.022949159Z    File "/tmp/8de117c79a5d4aa/main.py", line 3, in <module>
2025-10-22T15:19:14.022967539Z      from fastapi import FastAPI
2025-10-22T15:19:14.022986910Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/fastapi/__init__.py", line 7, in <module>
2025-10-22T15:19:14.022990217Z      from .applications import FastAPI as FastAPI
2025-10-22T15:19:14.023010105Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/fastapi/applications.py", line 16, in <module>
2025-10-22T15:19:14.023012742Z      from fastapi import routing
2025-10-22T15:19:14.023014951Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/fastapi/routing.py", line 27, in <module>
2025-10-22T15:19:14.023017389Z      from fastapi import params, temp_pydantic_v1_params
2025-10-22T15:19:14.023019534Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/fastapi/params.py", line 5, in <module>
2025-10-22T15:19:14.023021903Z      from fastapi.openapi.models import Example
2025-10-22T15:19:14.023024194Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/fastapi/openapi/models.py", line 4, in <module>
2025-10-22T15:19:14.023026653Z      from fastapi._compat import (
2025-10-22T15:19:14.023028773Z      ...<6 lines>...
2025-10-22T15:19:14.023031008Z      )
2025-10-22T15:19:14.023033117Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/fastapi/_compat/__init__.py", line 1, in <module>
2025-10-22T15:19:14.023035976Z      from .main import BaseConfig as BaseConfig
2025-10-22T15:19:14.023038109Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/fastapi/_compat/main.py", line 12, in <module>
2025-10-22T15:19:14.023040490Z      from fastapi._compat import may_v1
2025-10-22T15:19:14.023042746Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/fastapi/_compat/may_v1.py", line 4, in <module>
2025-10-22T15:19:14.023045220Z      from fastapi.types import ModelNameMap
2025-10-22T15:19:14.023047363Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/fastapi/types.py", line 5, in <module>
2025-10-22T15:19:14.023049743Z      from pydantic import BaseModel
2025-10-22T15:19:14.023051864Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/pydantic/__init__.py", line 5, in <module>
2025-10-22T15:19:14.023054231Z      from ._migration import getattr_migration
2025-10-22T15:19:14.023056349Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/pydantic/_migration.py", line 4, in <module>
2025-10-22T15:19:14.023523184Z      from pydantic.warnings import PydanticDeprecatedSince20
2025-10-22T15:19:14.023528463Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/pydantic/warnings.py", line 5, in <module>
2025-10-22T15:19:14.023531244Z      from .version import version_short
2025-10-22T15:19:14.023534598Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/pydantic/version.py", line 7, in <module>
2025-10-22T15:19:14.023543275Z      from pydantic_core import __version__ as __pydantic_core_version__
2025-10-22T15:19:14.023545807Z    File "/tmp/8de117c79a5d4aa/antenv/lib/python3.13/site-packages/pydantic_core/__init__.py", line 6, in <module>
2025-10-22T15:19:14.023548322Z      from typing_extensions import Sentinel
2025-10-22T15:19:14.023550539Z  ImportError: cannot import name 'Sentinel' from 'typing_extensions' (/agents/python/typing_extensions.py)

Ideally /agents/python/ would be later in PYTHONPATH, or would not contain python modules that clobber popular packages.

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