Skip to content

[Bug]: Regression in /beacons endpoints: BeaconState.model_validate(TortoiseModel) raises 500 when DB has rows #1073

@jmpereztorres

Description

@jmpereztorres

Before proceeding, is there an existing issue or discussion for this?

OS and version

macOS (local dev), running Kubernetes on Colima + kind

Open-RMF installation type

Docker

Other Open-RMF installation methods

rmf-web/api-server running in container on kind (local test stack)

Open-RMF version or commit hash

rmf-web commit: f33e755 Suspected regression introduced around: 88ab5b5 (routes/beacons.py migration from from_tortoise_orm to model_validate on ORM objects)

ROS distribution

Rolling

ROS installation type

Others

Other ROS installation methods

Containerized runtime inside api-server image

Package or library, if applicable

api-server (routes/beacons.py)

Description of the bug

/beacons endpoints return 500 Internal Server Error when the beaconstate table contains rows.

This appears to be a regression in packages/api-server/api_server/routes/beacons.py, where beacon ORM objects are passed directly to BeaconState.model_validate(...). With real DB rows, this raises a Pydantic validation error.

Affected endpoints:

  • GET /beacons
  • GET /beacons/{beacon_id}

Steps to reproduce the bug

  1. Run rmf-web api-server with DB backend (Docker deployment is fine).
  2. Insert at least one row into beaconstate, for example:
    • id='beacon_1'
    • online=true
    • category='elevator'
    • activated=true
    • level='L1'
  3. Call:
    • GET /beacons
    • GET /beacons/beacon_1

Observed result:

  • both endpoints return 500.

Relevant runtime error:
ValidationError: Input should be a valid dictionary or instance of BeaconState [input_value=<BeaconState: beacon_1>]

Expected behavior

  • GET /beacons should return 200 with a list of beacons.
  • GET /beacons/{beacon_id} should return 200 with the beacon payload.
  • No server-side validation exception should occur for valid rows in beaconstate.

Actual behavior

When the beaconstate table has at least one row:

  • GET /beacons returns 500 Internal Server Error
  • GET /beacons/{beacon_id} returns 500 Internal Server Error

Observed traceback (api-server logs):
pydantic_core._pydantic_core.ValidationError: Input should be a valid dictionary or instance of BeaconState [input_value=<BeaconState: beacon_1>, input_type=BeaconState]

This happens in:
packages/api-server/api_server/routes/beacons.py
when calling:
BeaconState.model_validate(db_beacon_row)

Additional information or screenshots

  • Affected file:
    https://github.com/open-rmf/rmf-web/blob/main/packages/api-server/api_server/routes/beacons.py
  • Likely regression introduced around:
    88ab5b59e7d93661c7625d4b0ccec08ea36d182e
  • Tested affected state on:
    f33e755b4d7c111f3b31ecf53e24ba876b9fb595
  • Historical note:
    older implementation (fd92cb32...) used Tortoise-to-Pydantic conversion (from_tortoise_orm) and did not have this failure mode.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions