Skip to content

FastAPI router routes don't propagate test context for replay mode #4366

@mfleader

Description

@mfleader

System Info

❯ python -m "torch.utils.collect_env"
<frozen runpy>:128: RuntimeWarning: 'torch.utils.collect_env' found in sys.modules after import of package 'torch.utils', but prior to execution of 'torch.utils.collect_env'; this may result in unpredictable behaviour
Collecting environment information...
PyTorch version: 2.8.0+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Fedora Linux 43 (Workstation Edition) (x86_64)
GCC version: (GCC) 15.2.1 20251111 (Red Hat 15.2.1-4)
Clang version: 21.1.6 (Fedora 21.1.6-1.fc43)
CMake version: version 3.31.6
Libc version: glibc-2.42

Python version: 3.12.12 (main, Nov 19 2025, 22:46:53) [Clang 21.1.4 ] (64-bit runtime)
Python platform: Linux-6.17.9-300.fc43.x86_64-x86_64-with-glibc2.42
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           46 bits physical, 48 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  20
On-line CPU(s) list:                     0-19
Vendor ID:                               GenuineIntel
Model name:                              12th Gen Intel(R) Core(TM) i7-12800H
CPU family:                              6
Model:                                   154
Thread(s) per core:                      2
Core(s) per socket:                      14
Socket(s):                               1
Stepping:                                3
CPU(s) scaling MHz:                      46%
CPU max MHz:                             4800.0000
CPU min MHz:                             400.0000
BogoMIPS:                                5606.40
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect user_shstk avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr ibt flush_l1d arch_capabilities
Virtualization:                          VT-x
L1d cache:                               544 KiB (14 instances)
L1i cache:                               704 KiB (14 instances)
L2 cache:                                11.5 MiB (8 instances)
L3 cache:                                24 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-19
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Old microcode:             Not affected
Vulnerability Reg file data sampling:    Mitigation; Clear Register File
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Enhanced / Automatic IBRS; IBPB conditional; PBRSB-eIBRS SW sequence; BHI BHI_DIS_S
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Mitigation; IBPB before exit to userspace

Versions of relevant libraries:
[pip3] Could not collect
[conda] Could not collect

Information

  • The official example scripts
  • My own modified scripts

🐛 Describe the bug

Problem
Integration tests in replay mode fail with ValueError: Test ID is required for file ID allocation when hitting APIs migrated to FastAPI routers.

Cause
@webmethod routes extract test context from headers via create_dynamic_typed_route(). FastAPI router routes bypass this, so generate_object_id() cannot allocate deterministic IDs.

Affected APIs
Any migrated API that calls generate_object_id() (e.g., Files, Vector IO).

Error logs

files

tests/integration/files/test_files.py::test_openai_client_basic_operations FAILED
tests/integration/files/test_files.py::test_files_authentication_shared_attributes FAILED
tests/integration/files/test_files.py::test_files_authentication_anonymous_access FAILED

tests/integration/files/test_files.py:47: in test_openai_client_basic_operations
    uploaded_file = client.files.create(file=file_buffer, purpose=purpose)
.venv/lib/python3.12/site-packages/openai/_base_client.py:1047: in request
    raise self._make_status_error_from_response(err.response) from None
E   openai.BadRequestError: Error code: 400 - {'error': {'detail': 'Invalid value: Test ID is required for file ID allocation'}}

vector_io

tests/integration/vector_io/test_openai_vector_stores.py::test_openai_vector_store_attach_file FAILED

tests/integration/vector_io/test_openai_vector_stores.py:671: in test_openai_vector_store_attach_file
    file = compat_client.files.create(
.venv/lib/python3.12/site-packages/openai/_base_client.py:1047: in request
    raise self._make_status_error_from_response(err.response) from None
E   openai.BadRequestError: Error code: 400 - {'error': {'detail': 'Invalid value: Test ID is required for file ID allocation'}}

Expected behavior

Integration tests pass in replay mode for APIs migrated to FastAPI routers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions