fix(common_utils.py): handle $id in response schema when calling vert… (#8991)

* fix(common_utils.py): handle $id in response schema when calling vertex ai

Fixes issue where `$id` present in response_schema was not accepted by vertex ai

* test(test_vertex.py): add unit test to ensure $id stripped out of vertex schema
This commit is contained in:
Krish Dholakia 2025-03-04 21:19:50 -08:00 committed by GitHub
parent 252c10ad08
commit ce2d7bf9e6
3 changed files with 8 additions and 0 deletions

View file

@ -170,6 +170,9 @@ def _build_vertex_schema(parameters: dict):
strip_field( strip_field(
parameters, field_name="$schema" parameters, field_name="$schema"
) # 5. Remove $schema - json schema value, not supported by OpenAPI - causes vertex errors. ) # 5. Remove $schema - json schema value, not supported by OpenAPI - causes vertex errors.
strip_field(
parameters, field_name="$id"
) # 6. Remove id - json schema value, not supported by OpenAPI - causes vertex errors.
return parameters return parameters

View file

@ -7059,6 +7059,9 @@ async def delete_model(model_info: ModelInfoDelete):
) )
except Exception as e: except Exception as e:
verbose_proxy_logger.exception(
f"Failed to delete model. Due to error - {str(e)}"
)
if isinstance(e, HTTPException): if isinstance(e, HTTPException):
raise ProxyException( raise ProxyException(
message=getattr(e, "detail", f"Authentication Error({str(e)})"), message=getattr(e, "detail", f"Authentication Error({str(e)})"),

View file

@ -108,6 +108,7 @@ def test_build_vertex_schema():
schema = { schema = {
"type": "object", "type": "object",
"$id": "my-special-id",
"properties": { "properties": {
"recipes": { "recipes": {
"type": "array", "type": "array",
@ -126,6 +127,7 @@ def test_build_vertex_schema():
assert new_schema["type"] == schema["type"] assert new_schema["type"] == schema["type"]
assert new_schema["properties"] == schema["properties"] assert new_schema["properties"] == schema["properties"]
assert "required" in new_schema and new_schema["required"] == schema["required"] assert "required" in new_schema and new_schema["required"] == schema["required"]
assert "$id" not in new_schema
@pytest.mark.parametrize( @pytest.mark.parametrize(