ValidationError: 1 validation error for RoutesFetchRoutesResponseBody
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start in the routes response model and the fetch_routes entry point corresponding to samsara/routes/raw_client.py:1385, then reproduce the request with an empty date range. Update the response handling so the shown {"data":null,...} response validates successfully, and add or run a regression test confirming that filtering a range with no data no longer raises ValidationError.
Written by the indexing model from the issue text.
Description
The response body for the fetch_routes should either allow for nulls, or the endpoint should be changed to return an empty list, otherwise we get the following error when filtering on a range without any data:
│ /site-packages/samsara/routes/raw_client.py:1385 in fetch_routes │
│ │
│ 1382 │ │ │ if 200 <= _response.status_code < 300: │
│ 1383 │ │ │ │ _data = typing.cast( │
│ 1384 │ │ │ │ │ RoutesFetchRoutesResponseBody, │
│ ❱ 1385 │ │ │ │ │ parse_obj_as( │
│ 1386 │ │ │ │ │ │ type_=RoutesFetchRoutesResponseBody, # type: ignore │
│ 1387 │ │ │ │ │ │ object_=_response.json(), │
│ 1388 │ │ │ │ │ ), │
│ │
│ /site-packages/samsara/core/pydantic_utilities.py:289 in parse_obj_as │
│ │
│ 286 │ │ dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read") │
│ 287 │ if IS_PYDANTIC_V2: │
│ 288 │ │ adapter = pydantic.TypeAdapter(type_) # type: ignore[attr-defined] │
│ ❱ 289 │ │ return adapter.validate_python(dealiased_object) │
│ 290 │ return pydantic.parse_obj_as(type_, dealiased_object) │
│ 291 │
│ 292 │
│ │
│ /site-packages/pydantic/type_adapter.py:441 in validate_python │
│ │
│ 438 │ │ │ │ code='validate-by-alias-and-name-false', │
│ 439 │ │ │ ) │
│ 440 │ │ │
│ ❱ 441 │ │ return self.validator.validate_python( │
│ 442 │ │ │ object, │
│ 443 │ │ │ strict=strict, │
│ 444 │ │ │ extra=extra, │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
ValidationError: 1 validation error for RoutesFetchRoutesResponseBody
data
Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
For further information visit https://errors.pydantic.dev/2.13/v/list_type
Request: GET https://api.samsara.com/fleet/routes?startTime=2026-07-07T21:51:02.225300Z&endTime=2026-07-08T21:51:02.225313Z with Authorization: Bearer <token>
Response: 200 OK, raw body:
{"data":null,"pagination":{"endCursor":"","hasNextPage":false}}
- Dominant language
- Python
- Stars
- 28
- Forks
- 12
- Avg merge
- 4h 26m
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from samsarahq/samsara-python
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
samsarahq/samsara-python#35 ·
-
Data Type mismatch in ReadingHistoryResponseBodyObject and the actual Response that api is giving Open
Difficulty 1/5 Under an hour Newbie friendliness 55/100
samsarahq/samsara-python#12 ·
All issues in samsarahq/samsara-python
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100