fix: BUG-04 webhook JSON Content-Type, BUG-05 obdJson list guard #13
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/bugs-04-05"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Second tranche of audit fixes — MEDIUM severity webhook robustness issues. Independent of PR #12 (no overlapping lines).
webhook_receiver_rev._parse_requestdocstring promised JSON-body support but the implementation only calledrequest.form(). A JSON push silently returned("", [])and dropped every record. Now branches onContent-Type: parsesapplication/jsondirectly into{token, data_list|data}, falls back to the form path that matches live Jimi behaviour. Accepts both pre-parsed and string-encoded inner payloads.push_obdassumedobdJsonparsed to a dict, but malformed payloads can produce a list. The laterobd.get()raisedAttributeError, was caught by the per-item except, and was logged as a generic "Failed to process" warning — silently losing the reading. Now coerces lists to their first dict element and falls back to{}for anything else.Test plan
application/jsonPOST to/pushgpsvia curl (token + data_list with one record); confirm a row lands intracksolid.position_history.application/x-www-form-urlencodedPOST to the same endpoint; confirm the form path still works (regression check)./pushobdPOST whereobdJsonis a JSON array string[{"event_time": ...}]; confirm one row intracksolid.obd_readingsinstead of a warning + drop.tracksolid.ingestion_logover the next 24h for any change insuccess=falserows for webhook endpoints.🤖 Generated with Claude Code
BUG-04 (MEDIUM): the _parse_request docstring promised "JSON body or form-encoded body" support, but the implementation only called request.form(). If Jimi sent application/json (per the docs), the form parse returned an empty FormData, the function returned ("", []), and the entire push was silently dropped. Now branches on Content-Type and parses JSON bodies directly, falling back to the form path that matches the live Jimi behaviour. BUG-05 (MEDIUM): push_obd treated obdJson as a dict after json.loads even though malformed payloads can decode to a list. The subsequent obd.get(...) raised AttributeError, caught by the per-item except and logged as a generic "Failed to process" warning — silently losing the reading. Now coerces lists to their first dict element and falls back to {} for any other non-dict shape so the timestamp/lat/lng extraction still runs. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.