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
6 changes: 4 additions & 2 deletions aiola/clients/stt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def __init__(self, options: AiolaClientOptions, auth: AuthClient | AsyncAuthClie
def _build_url(self, query_params: dict[str, str]) -> str:
"""Return base URL with encoded query parameters."""
try:
return f"{self._options.base_url}?{urlencode(query_params)}"
# Filter out None values from query parameters
filtered_params = {k: v for k, v in query_params.items() if v is not None}
return f"{self._options.base_url}?{urlencode(filtered_params)}"
except Exception as exc:
raise AiolaError("Failed to build streaming URL") from exc

Expand Down Expand Up @@ -66,7 +68,7 @@ def _build_query_and_headers(
"lang_code": lang_code or "en",
"time_zone": time_zone or "UTC",
"keywords": json.dumps(keywords or {}),
"tasks_config": json.dumps(tasks_config or {}),
"tasks_config": json.dumps(tasks_config) if tasks_config is not None else None,
"x-aiola-api-token": access_token,
}

Expand Down
7 changes: 3 additions & 4 deletions tests/unit/stt/test_stt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,14 @@ def test_stt_stream_with_no_tasks_config(patch_dummy_socket):
# Access the underlying socket to validate connection parameters
sio = connection._sio

# Verify None tasks_config is serialized as empty JSON object
# Verify None tasks_config is excluded from URL parameters
kwargs = sio.connect_kwargs
url = kwargs["url"]
parsed = urllib.parse.urlparse(url)
query = urllib.parse.parse_qs(parsed.query)

tasks_config_json = query["tasks_config"][0]
parsed_tasks_config = json.loads(tasks_config_json)
assert parsed_tasks_config == {}
# tasks_config should not be present in query parameters when None
assert "tasks_config" not in query


def test_stt_stream_with_all_tasks_config(patch_dummy_socket):
Expand Down