From 4c8516673472a53f3e0cb8297172d28f21ab15c8 Mon Sep 17 00:00:00 2001 From: Nora Date: Tue, 7 Jul 2026 11:42:07 -0600 Subject: [PATCH] fix(sp37): align submission router with package conventions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Code review of f1dc06e flagged 3 consistency outliers vs every other gated router in api_routers/: - Drop prefix='/api' from APIRouter. Every sibling (clearhouse, parse, claims, batches, inbox, acks, ta1_acks, claim_acks, remittances, providers, reconciliation, activity, eligibility, dashboard, admin, config, payers, acks) declares the full path in the decorator instead. Submission was the only one with prefix='/api' + '/submit-batch'. - Rename handler post_submit_batch -> submit_batch. Siblings use verb_noun (submit_to_clearhouse, export_batch_837, etc.). The 'post_' prefix was unique to this file. - Move 'from cyclone.store import store as cycl_store' from inside the handler to the module top. Sibling routers all import store at module top — the lazy-import rationale in the inline comment was wrong; pulling store at module import time is fine (the rest of the package already does it). Tests: tests/test_api_submit_batch.py + tests/test_submission.py + tests/test_batch_txn_set_cn.py + tests/test_batch_envelope_index_sp37.py = 26 passed in 1.37s (no behavior change, just naming). --- backend/src/cyclone/api_routers/submission.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/cyclone/api_routers/submission.py b/backend/src/cyclone/api_routers/submission.py index 9a69c11..938f246 100644 --- a/backend/src/cyclone/api_routers/submission.py +++ b/backend/src/cyclone/api_routers/submission.py @@ -32,13 +32,16 @@ from fastapi import APIRouter, Depends, HTTPException from pydantic import BaseModel, ConfigDict, Field from cyclone.auth.deps import matrix_gate +from cyclone.store import store as cycl_store from cyclone.submission.core import submit_file from cyclone.submission.result import SubmitOutcome, SubmitResult log = logging.getLogger(__name__) +# No `prefix=` here — every other gated router in this package declares +# the full path in the decorator (clearhouse.py uses "/api/clearhouse", +# parse.py uses "/api/parse-837", etc.). The decorator sets the full URL. router = APIRouter( - prefix="/api", tags=["submission"], dependencies=[Depends(matrix_gate)], ) @@ -69,8 +72,8 @@ class SubmitBatchRequest(BaseModel): limit: int | None = None -@router.post("/submit-batch") -def post_submit_batch(body: SubmitBatchRequest): +@router.post("/api/submit-batch") +def submit_batch(body: SubmitBatchRequest): """Submit every ``batch-*-claims/*.x12`` under ``ingest_dir``. Walks ``ingest_dir`` for any directory matching ``batch-*-claims``, @@ -84,7 +87,6 @@ def post_submit_batch(body: SubmitBatchRequest): HTTP status code — the response is 200 whenever the run itself completed. """ - from cyclone.store import store as cycl_store # 1. Config-level guards. Order matters: a missing clearhouse is a # 404 (config-level "missing"), but if it IS present and in stub