mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-12 23:05:52 +00:00
3f33efdd57
* fix(tests): drop import-time completion call in test_register_model test_update_model_cost_via_completion() was invoked at module scope, so it ran during pytest collection and fired a live OpenAI completion. The local test jobs glob the whole tests/local_testing folder and let pytest import every file, narrowing what runs only afterward with -k, so this call executed in every one of those jobs regardless of their filter. When the request failed (for instance a 429 once the OpenAI account hit its quota), collection of the file errored and aborted the entire session, which is why langfuse, assistants, router and local_testing_part2 all reported "ERROR collecting tests/local_testing/test_register_model.py" and never ran their own tests. Remove the stray call and add a regression that parses the module and fails if any locally defined function is invoked at module scope again * test: also guard async def from module-scope invocation ast.AsyncFunctionDef is a distinct node from ast.FunctionDef, so an async test invoked at module scope would have slipped past the guard. Collect both kinds of definitions * fix(responses): send Content-Type application/json on OpenAI responses requests OpenAI's responses API now rejects body-less requests (GET/DELETE) that arrive without a content type, returning 500 "Unsupported content type: 'application/octet-stream'. This API method only accepts 'application/json' requests". litellm's create path got the header for free because httpx sets it when a json body is present, but the delete/get handlers send no body and so sent no content type. The official OpenAI SDK declares Content-Type: application/json on every request; mirror that in validate_environment so all OpenAI responses calls carry it. This is what made tests/openai_endpoints_tests/test_e2e_openai_responses_api.py::test_basic_response fail on the responses.delete() call.