fix(stt): xAI 400 при format=true без language — убираем поле format
CI / test (push) Successful in 7m50s
CI / deploy-ift (push) Successful in 3m56s
CI / e2e-ift (push) Successful in 1m18s
CI / deploy-stage (push) Successful in 2m16s
CI / e2e-stage (push) Successful in 1m11s

Smoke на IFT: xAI отвечает 400 "Field 'language' is required when
'format' is true" → бэк маппит в 502 upstream_error. Проверено curl:
без поля format эндпоинт /v1/stt работает (200), язык определяется
автоматически. Убрано поле format из multipart xAI-адаптера, eunit
обновлён (полный прогон: 1211 тестов зелёные).

Refs EventHub/EventHubBack#79
This commit is contained in:
2026-08-21 21:32:13 +03:00
parent 1ef9020c40
commit d46eb6e528
2 changed files with 5 additions and 7 deletions
+3 -2
View File
@@ -125,8 +125,9 @@ env_int(Name, Default) ->
%%%===================================================================
call_provider(xai, Url, Key, Audio, CType) ->
%% xAI: multipart; опциональные поля до поля file, file — последним.
Body = build_multipart([{<<"format">>, <<"true">>}], Audio, <<"voice.dat">>, CType),
%% xAI: multipart без опциональных полей — язык определяется авто
%% (format=true требует явный language и отключает автоопределение).
Body = build_multipart([], Audio, <<"voice.dat">>, CType),
post_and_parse(xai, Url, Key, Body);
call_provider(openai, Url, Key, Audio, CType) ->
Model = case env_bin("STT_MODEL") of
+2 -5
View File
@@ -56,13 +56,10 @@ test_xai_success() ->
?assertEqual(?XAI_URL, Url),
?assertEqual([{"authorization", "Bearer test-key"}], Headers),
?assertMatch("multipart/form-data; boundary=" ++ _, ContentType),
?assertMatch({_, _}, binary:match(Body, <<"name=\"format\"">>)),
?assertMatch({_, _}, binary:match(Body, <<"name=\"file\"">>)),
?assertMatch({_, _}, binary:match(Body, <<"audio-bytes">>)),
%% Поле file — последнее (требование xAI).
{PosFormat, _} = binary:match(Body, <<"name=\"format\"">>),
{PosFile, _} = binary:match(Body, <<"name=\"file\"">>),
?assert(PosFormat < PosFile).
%% Без поля format — язык определяется авто (format=true требует language).
?assertEqual(nomatch, binary:match(Body, <<"name=\"format\"">>)).
test_openai_adapter() ->
os:putenv("STT_PROVIDER", "openai"),