feat(obd_ai): add normalized JSON serializers - #11
virtuscyber wants to merge 1 commit into
Conversation
🤖 Augment PR SummarySummary: This PR introduces JSON-safe, normalized serializers for python-OBD responses and related diagnostic primitives, and exposes them through the package API. Changes:
🤖 Was this summary useful? React with 👍 or 👎 |
| return raw.decode("ascii") | ||
| except UnicodeDecodeError: | ||
| return raw.hex() | ||
| return str(raw) |
There was a problem hiding this comment.
_serialize_command_bytes() falls back to str(raw), which will turn None into the string "None" (e.g., if command.header is unset) instead of JSON null, breaking the JSON-safe contract. Consider ensuring None remains None at this boundary.
Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| return { | ||
| "type": "connection_metadata", | ||
| "status": status, | ||
| "is_connected": is_connected, |
There was a problem hiding this comment.
serialize_connection_metadata() returns status as-is; if callers pass an OBDStatus enum/object, this may not be JSON-serializable and may violate the documented status: str contract. Consider normalizing status to a plain string at the serializer boundary.
Severity: medium
Other Locations
obd_ai/session.py:70
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| code, description = value | ||
| return { | ||
| "type": "dtc", | ||
| "code": code, |
There was a problem hiding this comment.
_is_dtc_entry() matches codes case-insensitively via code.upper(), but _serialize_dtc_entry() emits the original code, so inputs like p0101 would produce non-normalized output. If the goal is a normalized JSON contract, consider emitting the uppercased code.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
Refs #2
Stacked on top of #1.
Includes: