Skip to content
Open
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
4 changes: 3 additions & 1 deletion packages/sie_server/src/sie_server/api/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ def resolve_runtime_options_with_profile(
) from e

overflow_policy = merged.get("overflow_policy")
if overflow_policy is not None and overflow_policy not in VALID_OVERFLOW_POLICIES:
if overflow_policy is not None and (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test? Nothing in the suite currently touches this validation branch at all. No test references invalid_overflow_policy. so right now nothing proves the fix works and nothing stops it coming back. A single case asserting {"overflow_policy": ["truncate_text"]} returns 400 would cover it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay will be done

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test covering the invalid overflow_policy type case. It verifies that passing a list returns the expected 400 INVALID_INPUT response.

not isinstance(overflow_policy, str) or overflow_policy not in VALID_OVERFLOW_POLICIES
):
span.set_attribute("error", "invalid_overflow_policy")
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
Expand Down
34 changes: 34 additions & 0 deletions packages/sie_server/tests/api/test_option.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from unittest.mock import MagicMock

import pytest
from fastapi import HTTPException
from sie_server.api.options import resolve_runtime_options_with_profile
from sie_server.config.model import EmbeddingDim, EncodeTask, ModelConfig, ProfileConfig, Tasks


def _make_config() -> ModelConfig:
return ModelConfig(
sie_id="test",
hf_id="org/test",
tasks=Tasks(encode=EncodeTask(dense=EmbeddingDim(dim=8))),
profiles={
"default": ProfileConfig(
adapter_path="sie_server.adapters.base:ModelAdapter",
max_batch_tokens=8,
)
},
)


def test_invalid_overflow_policy_type_returns_400() -> None:
span = MagicMock()

with pytest.raises(HTTPException) as exc_info:
resolve_runtime_options_with_profile(
_make_config(),
{"overflow_policy": ["truncate_text"]},
span,
)

assert exc_info.value.status_code == 400
assert exc_info.value.detail["code"] == "INVALID_INPUT"