Compare commits

..

2 commits

Author SHA1 Message Date
f42eef6653 Merge pull request 'diag: log raw push body to identify Jimi format' (#7) from quality-program-2026-04-12 into main
Some checks are pending
Static Analysis / static (push) Waiting to run
Tests / test (push) Waiting to run
2026-04-21 09:05:09 +00:00
David Kiania
c54794eb4c diag: log raw push body + content-type at INFO level
Some checks failed
Static Analysis / static (push) Waiting to run
Tests / test (push) Waiting to run
Static Analysis / static (pull_request) Has been cancelled
Tests / test (pull_request) Has been cancelled
Temporary diagnostic to see what format Jimi actually sends on /pushalarm.
New container is parsing to empty items (pushes arrive but no DB insert),
so we need to see the real body shape. Remove once format is confirmed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 12:04:55 +03:00

View file

@ -112,8 +112,12 @@ async def _parse_request(request: Request) -> tuple[str, list[dict]]:
content_type = request.headers.get("content-type", "")
body = await request.body()
# TEMP DIAGNOSTIC: log every push so we can see what Jimi actually sends.
log.info("push %s: content-type=%r body=%.300s",
request.url.path, content_type,
body.decode("utf-8", errors="replace") if body else "<empty>")
if not body:
log.debug("push: empty request body")
return "", []
# ── Try JSON body first (integration push format) ──────────────────────────
@ -128,11 +132,10 @@ async def _parse_request(request: Request) -> tuple[str, list[dict]]:
items = _parse_data_list(raw_dl)
else:
items = []
log.debug("push: parsed JSON body — %d items", len(items))
log.info("push: parsed JSON body — %d items", len(items))
return token, items
except (json.JSONDecodeError, TypeError):
log.warning("push: JSON body parse failed — body: %.200s",
body.decode("utf-8", errors="replace"))
log.warning("push: JSON body parse failed")
# ── Fall back to form-encoded ───────────────────────────────────────────────
try:
@ -140,11 +143,10 @@ async def _parse_request(request: Request) -> tuple[str, list[dict]]:
token = str(form.get("token", ""))
raw_dl = str(form.get("data_list", ""))
items = _parse_data_list(raw_dl) if raw_dl else []
log.debug("push: parsed form body — %d items", len(items))
log.info("push: parsed form body — %d items", len(items))
return token, items
except Exception:
log.warning("push: form body parse failed — body: %.200s",
body.decode("utf-8", errors="replace"), exc_info=True)
log.warning("push: form body parse failed", exc_info=True)
return "", []