Skip to content

BRP requests without params are rejected, even for paramless methods #23643

@splo

Description

@splo

Bevy version and features

  • main at commit 53ddd5e615ae15ad796b36724ddd67516bec0c84.
  • Relevant area: crates/bevy_remote.

What you did

I sent a BRP request over HTTP to a method that does not need any params, for example rpc.discover (other methods are affected as well), without including a params field:

curl --request POST \
  --url http://localhost:15702/ \
  --header 'content-type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "rpc.discover"
}'

What went wrong

  • Expected: successful response with the method result.
  • Actual: error response indicating that the params field is missing:
{
  "jsonrpc": "2.0",
  "id": 0,
  "error": {
    "code": -32600,
    "message": "missing field `params`"
  }
}

This is a regression. The documentation states:

The params field may be omitted for certain methods.

Additional information

Passing params: null works:

curl --request POST \
  --url http://localhost:15702/ \
  --header 'content-type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 0,
  "method": "rpc.discover",
  "params": null
}'

This is likely a result of the recent PR #23175 that introduced a custom (de)serializer for BrpRequest.

let params = params.ok_or_else(|| de::Error::missing_field("params"))?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-Dev-ToolsTools used to debug Bevy applications.C-BugAn unexpected or incorrect behaviorD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesP-RegressionFunctionality that used to work but no longer does. Add a test for this!S-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions