litellm/tests/unit/proxy/openai_files_endpoint
paveln83 7d4c0ab91a
fix(proxy): retrieve and delete a managed file when the request also names a model (#51780)
* fix(proxy): retrieve and delete a managed file when the request also names a model

GET and DELETE /v1/files/{id} sent a proxy-managed file id to the provider unchanged whenever the x-litellm-model header or ?model= named a model, so the provider answered 404 and DELETE left the file in place. A managed file id now skips model-based routing and resolves to each deployment's provider file id, as the content route already did.

* fix(proxy): keep forwarding a managed file id by the model hint on a proxy without a database

A proxy with no database loads no managed files hook, so it cannot resolve a
managed file id itself and must keep sending it to the named model, which may be
another LiteLLM proxy that owns the file. Skip model routing for a managed id only
when the managed files hook is loaded.

The tests now run the real managed files hook over a stored row with only the
OpenAI file routes faked, and cover the no-database proxy.

* test(proxy): type the managed file table helper's delete filter

* test(proxy): keep a raw provider file id routed by the model hint when managed files are on

A proxy with a database loads the managed files hook, which now skips model routing for its own file ids. This test makes sure a raw provider file id sent with a model hint on that proxy still goes to the hinted deployment with its credentials, so the skip cannot widen to every id unnoticed

* test(proxy): cover a model hint that names a model the managed file is not on

A hint naming another deployment must still resolve the managed id through the managed files hook, so these cases fail if routing is skipped only when the hint matches the file's own model

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-14 04:55:36 -05:00
..
__init__.py test(proxy): move utils, agent_endpoints and endpoint tests into tests/unit/proxy (#44006) 2026-10-01 11:06:42 -07:00
test_batch_guardrails.py refactor(proxy): expose public names for private proxy helpers (#45170) 2026-10-07 18:59:27 -07:00
test_file_usage_caps.py feat(proxy): cap batch file records, daily batch uploads, and per-file downloads (#43632) 2026-10-06 03:06:36 +00:00
test_files_batch_file_validation.py fix(vertex_ai): return 400 with file line number for malformed batch JSONL row (#40097) 2026-10-15 03:21:48 -07:00
test_files_common_utils.py fix(files): match every spelling of a provider file id in the ownership check (#51498) 2026-11-13 05:43:43 +00:00
test_files_endpoint.py fix(proxy): retrieve and delete a managed file when the request also names a model (#51780) 2026-11-14 04:55:36 -05:00
test_general_upload_validation.py test(proxy): move utils, agent_endpoints and endpoint tests into tests/unit/proxy (#44006) 2026-10-01 11:06:42 -07:00
test_storage_backend_service.py refactor(typing): clear 1181 basedpyright Any errors across 431 files (#47789) 2026-10-24 11:31:09 -07:00