ValidationError: 1 validation error for RoutesFetchRoutesResponseBody

Open Beginner friendly
#147 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python
Domain
api

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from samsarahq/samsara-python

All issues in samsarahq/samsara-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.