Skip to content

fix(sdk,core): make TrackingEvent.description optional end-to-end#1077

Merged
Dan (danh91) merged 2 commits into
mainfrom
hotfix/tracking-event-description-optional
Apr 29, 2026
Merged

fix(sdk,core): make TrackingEvent.description optional end-to-end#1077
Dan (danh91) merged 2 commits into
mainfrom
hotfix/tracking-event-description-optional

Conversation

@danh91

@danh91 Dan (danh91) commented Apr 29, 2026

Copy link
Copy Markdown
Member

Bug

Tracking calls against carriers whose upstream omitted (or nulled) the description field on any single event returned 500 with:

TrackingEvent.__init__() missing 1 required positional argument: 'description'

Reproduced in production against SmartKargo with request_log 29962 — the MDL event in the response has "description": null, which propagated through the carrier schema as e.description = None. Every connector that hands description=e.description straight into the unified model has the same exposure.

Root Cause Audit

Layer File Status before
SDK unified model modules/sdk/karrio/core/models.py:347 description: strrequired positional
Server REST serializer (DRF) modules/core/karrio/server/core/serializers.py:1237 CharField(required=False) — missing allow_blank / allow_null
Django model modules/manager/karrio/server/manager/models.py:689 events = JSONField(...) — no per-field constraints, fine
GraphQL type modules/graph/karrio/server/graph/schemas/base/types.py:1348 description: typing.Optional[str] = None — already fine

Fix

Two coordinated edits so a null description survives the SDK → server → API JSON round-trip:

# modules/sdk/karrio/core/models.py
     date: str
-    description: str
+    description: str = None
     code: str = None
# modules/core/karrio/server/core/serializers.py
     description = serializers.CharField(
-        required=False, help_text="The tracking event's description"
+        required=False,
+        allow_blank=True,
+        allow_null=True,
+        help_text="The tracking event's description",
     )

Tests

No SDK test existed for TrackingEvent previously — adding one for a one-line attrs default would be ceremonial. Server-level: existing tracker tests round-trip events through the JSONField, and the serializer change just brings description in line with siblings (time, code, status). Production smoke: the SmartKargo MDL payload from request_log 29962 is the regression to watch.

@vercel

vercel Bot commented Apr 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
karrio-web Ready Ready Preview, Comment Apr 29, 2026 4:17am

Request Review

Carriers can return events with null/missing descriptions (e.g. SmartKargo
MDL events). The unified SDK model required `description` as a positional
argument, so connectors hit
`TrackingEvent.__init__() missing 1 required positional argument: 'description'`
and the whole tracking response failed with a 500 even though the upstream
call succeeded.

Two coordinated changes so a null description from any carrier survives
the full pipeline (SDK → server serializer → JSON response):

- modules/sdk/karrio/core/models.py: default `description` to None on
  the unified TrackingEvent — aligns with every other field on the type.
- modules/core/karrio/server/core/serializers.py: add allow_blank+allow_null
  to the DRF TrackingEvent.description field so the API serializer accepts
  and round-trips null descriptions, matching siblings (time, code, status).

Django storage is unaffected — Tracking.events is a JSONField, no per-field
constraints. GraphQL TrackingEventType already has description Optional[str].
@danh91
Dan (danh91) force-pushed the hotfix/tracking-event-description-optional branch from 77cb12e to 10009e2 Compare April 29, 2026 03:56
@danh91 Dan (danh91) changed the title fix(sdk): make TrackingEvent.description optional fix(sdk,core): make TrackingEvent.description optional end-to-end Apr 29, 2026
Hotfix release for null description on tracking events. Lookups against
carriers whose upstream omitted/nulled `description` on any single event
returned a 500 with
`TrackingEvent.__init__() missing 1 required positional argument: 'description'`
because the unified SDK model required `description` as a positional and the
DRF serializer didn't allow nulls.

The SDK `models.TrackingEvent.description` now defaults to None and the DRF
`TrackingEvent.description` field sets allow_blank=True, allow_null=True so a
null description from any carrier survives the SDK → server → API JSON
round-trip. Django storage (JSONField) and GraphQL (Optional[str]) were
already permissive.
@danh91
Dan (danh91) merged commit 41532e2 into main Apr 29, 2026
14 of 15 checks passed
@danh91
Dan (danh91) deleted the hotfix/tracking-event-description-optional branch April 29, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant