merge: SP28 follow-up — fix Batch.kind '837' vs '837p' mismatch

Hotfix for the SP28 merge. The SP28 helpers (batch_envelope_index +
the two _batch_lookup closures in handle_ta1 / api.py) all filtered
Batch.kind == '837', but prod Batch rows are persisted with kind='837p'
(see api.py:443). Result on prod: claim_acks row count = 0, D10 Pass 1
(ST02 via batch.envelope.control_number) never fired, and the user's
specific claim t991102989o1c120d would not surface its 143 999 acks.

Fix: 4 production sites swapped to '837p'; 3 test files updated to
match the prod value. 25 SP28 tests + 20 handler tests pass post-fix.
Expected prod effect after re-deploy: 727 of 1,398 acks auto-link via
batch.envelope.control_number, plus the user's claim surfaces in
ClaimDrawer for /api/claims/t991102989o1c120d/acks.

Follow-up plan: backfill the existing 1,398 acks via a one-time script
that runs the SP28 helpers against the current DB (D10 join now
resolves the 991102989 ST02 from existing batches).
This commit is contained in:
Nora
2026-07-02 12:22:36 -06:00
7 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -941,7 +941,7 @@ async def parse_ta1_endpoint(
rows = (
link_s.query(Batch)
.filter(
Batch.kind == "837",
Batch.kind == "837p",
Batch.raw_result_json.isnot(None),
)
.order_by(Batch.parsed_at.desc())
+1 -1
View File
@@ -141,7 +141,7 @@ def lookup_claims_for_ack_set_response(
# callers SHOULD pass the index.
rows = (
session.query(Batch.id, Batch.raw_result_json)
.filter(Batch.kind == "837")
.filter(Batch.kind == "837p")
.all()
)
for bid, raw in rows:
+1 -1
View File
@@ -75,7 +75,7 @@ def handle(
rows = (
session.query(db.Batch)
.filter(
db.Batch.kind == "837",
db.Batch.kind == "837p",
db.Batch.raw_result_json.isnot(None),
)
.order_by(db.Batch.parsed_at.desc())
+1 -1
View File
@@ -78,7 +78,7 @@ def batch_envelope_index() -> dict[str, str]:
with db.SessionLocal()() as s:
rows = (
s.query(Batch.id, Batch.raw_result_json)
.filter(Batch.kind == "837")
.filter(Batch.kind == "837p")
.all()
)
for bid, raw in rows:
+1 -1
View File
@@ -56,7 +56,7 @@ def _seed_batch_envelope(*, batch_id: str, envelope_control: str):
with db.SessionLocal()() as s:
b = Batch(
id=batch_id,
kind="837",
kind="837p",
input_filename=f"{batch_id}.txt",
parsed_at=datetime(2026, 7, 2, 12, 0, tzinfo=timezone.utc),
raw_result_json={
+2 -2
View File
@@ -78,7 +78,7 @@ def _seed_batch(
``batch_envelope_index``."""
b = Batch(
id=batch_id,
kind="837",
kind="837p",
input_filename=f"{batch_id}.txt",
parsed_at=datetime(2026, 7, 2, 12, 0, tzinfo=timezone.utc),
raw_result_json={
@@ -378,7 +378,7 @@ def test_ta1_links_to_most_recent_matching_batch():
def _batch_lookup(sender_id, receiver_id):
rows = (
s.query(Batch)
.filter(Batch.kind == "837")
.filter(Batch.kind == "837p")
.order_by(Batch.parsed_at.desc())
.all()
)
@@ -64,7 +64,7 @@ def _seed_batch_envelope(*, batch_id: str, envelope_control: str):
with db.SessionLocal()() as s:
b = Batch(
id=batch_id,
kind="837",
kind="837p",
input_filename=f"{batch_id}.txt",
parsed_at=datetime(2026, 7, 2, 12, 0, tzinfo=timezone.utc),
raw_result_json={