Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion litellm/proxy/common_utils/http_parsing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def get_tags_from_request_body(request_body: dict) -> List[str]:
List of tag names (strings), empty list if no valid tags found
"""
metadata_variable_name = get_metadata_variable_name_from_kwargs(request_body)
metadata = request_body.get(metadata_variable_name, {})
metadata = request_body.get(metadata_variable_name) or {}
tags_in_metadata: Any = metadata.get("tags", [])
tags_in_request_body: Any = request_body.get("tags", [])
combined_tags: List[str] = []
Expand Down
23 changes: 21 additions & 2 deletions tests/test_litellm/proxy/common_utils/test_http_parsing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,27 @@ def test_get_tags_from_request_body_with_dict_tags():
}
}
}

result = get_tags_from_request_body(request_body=request_body)


assert result == []
assert isinstance(result, list)


def test_get_tags_from_request_body_with_null_metadata():
"""
Test that function handles null metadata gracefully without crashing.

This is a regression test for https://github.com/BerriAI/litellm/issues/17263
When metadata is explicitly set to null/None, the function should return
an empty list instead of raising AttributeError.
"""
request_body = {
"model": "gpt-4",
"metadata": None # OpenAI API accepts metadata: null
}

result = get_tags_from_request_body(request_body=request_body)

assert result == []
assert isinstance(result, list)
Loading