diff --git a/services/api-server/src/api_server/html5_ai_structure.py b/services/api-server/src/api_server/html5_ai_structure.py index 2bbb3c2..58c2761 100644 --- a/services/api-server/src/api_server/html5_ai_structure.py +++ b/services/api-server/src/api_server/html5_ai_structure.py @@ -25,6 +25,7 @@ def render_html5_ai_structure_page(*, project_id: str, projects: Iterable[object Подготовка структуры {render_html5_ai_structure_form(project_id)} + Пути должны быть доступны серверу SFERA/API. Для docker-test используйте папку, смонтированную или доступную внутри контейнера; локальные диски Windows и закрытые SMB-папки без учетных данных сервер не увидит. {render_html5_ai_structure_result(result)} @@ -43,11 +44,11 @@ def render_html5_ai_structure_form(project_id: str) -> str: > Папка с cf/cfe или выгрузкой - + Папка результата - + Project id @@ -85,6 +86,21 @@ def render_html5_ai_structure_result(result: dict | None) -> str: """ +def render_html5_ai_structure_error(message: str) -> str: + return f""" + + + ошибка + Подготовка не выполнена + + + {escape(message)} + + Проверьте, что входная и выходная папки доступны именно серверу SFERA/API. Если файлы лежат на рабочем ПК, сначала положите их в общую папку или выполните экспорт через агент. + + """ + + def _diagnostics(items: list[object]) -> str: if not items: return "" diff --git a/services/api-server/src/api_server/html5_ai_structure_controller.py b/services/api-server/src/api_server/html5_ai_structure_controller.py index 81787d1..e581167 100644 --- a/services/api-server/src/api_server/html5_ai_structure_controller.py +++ b/services/api-server/src/api_server/html5_ai_structure_controller.py @@ -6,7 +6,11 @@ from typing import Any from fastapi import HTTPException -from api_server.html5_ai_structure import render_html5_ai_structure_page, render_html5_ai_structure_result +from api_server.html5_ai_structure import ( + render_html5_ai_structure_error, + render_html5_ai_structure_page, + render_html5_ai_structure_result, +) from api_server.html5_forms import form_value @@ -28,8 +32,15 @@ def html5_ai_structure_run( input_path = form_value(form, "input_path") output_path = form_value(form, "output_path") if not input_path: - raise HTTPException(status_code=400, detail="input_path is required") + return render_html5_ai_structure_error("Заполните входную папку с .cf/.cfe или выгрузкой 1С.") if not output_path: - raise HTTPException(status_code=400, detail="output_path is required") - result = prepare(project_id=effective_project_id, input_path=Path(input_path), output_path=Path(output_path)) + return render_html5_ai_structure_error("Заполните папку результата.") + try: + result = prepare(project_id=effective_project_id, input_path=Path(input_path), output_path=Path(output_path)) + except FileNotFoundError as error: + return render_html5_ai_structure_error(str(error)) + except PermissionError as error: + return render_html5_ai_structure_error(f"Нет доступа к папке: {error}") + except OSError as error: + return render_html5_ai_structure_error(f"Ошибка файловой системы: {error}") return render_html5_ai_structure_result(result) diff --git a/services/api-server/tests/test_api.py b/services/api-server/tests/test_api.py index 55e009e..6b87b2b 100644 --- a/services/api-server/tests/test_api.py +++ b/services/api-server/tests/test_api.py @@ -1727,7 +1727,14 @@ def test_ai_structure_prepare_writes_ai_ready_package(tmp_path: Path): assert "Treat modules/forms/commands as parts" in (output / "ai_context.md").read_text(encoding="utf-8") page = client.get("/html5/projects/ai-demo/ai-structure") - assert_html5_response_contract(page, 'data-html5-page="ai-structure"', "Структура для ИИ", full_page=True) + assert_html5_response_contract( + page, + 'data-html5-page="ai-structure"', + "Структура для ИИ", + "192.168.220.200", + "Пути должны быть доступны серверу", + full_page=True, + ) html5_run = client.post( "/html5/projects/ai-demo/ai-structure/run", @@ -1735,6 +1742,12 @@ def test_ai_structure_prepare_writes_ai_ready_package(tmp_path: Path): ) assert_html5_response_contract(html5_run, "ready", "codex-1c-context-ai-demo-html5", "sir_snapshot.json", "normalized_project.json") + html5_missing = client.post( + "/html5/projects/ai-demo/ai-structure/run", + data={"project_id": "ai-demo-html5", "input_path": str(tmp_path / "missing"), "output_path": str(tmp_path / "html5-out")}, + ) + assert_html5_response_contract(html5_missing, "ошибка", "Input path not found") + def test_ai_structure_prepare_reports_cf_cfe_export_required(tmp_path: Path): source = tmp_path / "cf-source"
Пути должны быть доступны серверу SFERA/API. Для docker-test используйте папку, смонтированную или доступную внутри контейнера; локальные диски Windows и закрытые SMB-папки без учетных данных сервер не увидит.
Проверьте, что входная и выходная папки доступны именно серверу SFERA/API. Если файлы лежат на рабочем ПК, сначала положите их в общую папку или выполните экспорт через агент.