Skip to content

Map<String, dynamic> as an Endpoint Parameter #3231

Closed

Description

@AmoonPod

Problem to Solve

Currently, Serverpod restricts Map parameters in endpoint methods to strictly typed maps (e.g., Map<String, int?>, Map<String, String?>, etc.). This limitation prevents the direct use of dynamic JSON objects—such as those produced by jsonDecode()—which makes it challenging to handle cases where payloads may vary or be invalid. As a result, when a client sends an incorrect payload, the system returns a generic Serverpod log error rather than a tailored response that could improve error handling and client feedback.

Proposal

Add support for passing a Map<String, dynamic> as an endpoint parameter.

Use Case

If a client sends a payload with an unexpected structure or incorrect data types, I currently only receive a generic Serverpod log error. With the ability to pass Map<String, dynamic>, I could:

Directly pass JSON-decoded maps to my endpoints.
Validate the payload within the endpoint.
Return custom, meaningful error messages to the client, improving the overall API experience.

Alternatives

No

Additional context

No response

How experienced are you with this library?

Expert - Experienced and comfortable with using this library in complex projects

Are you interested in working on a PR for this?

  • I want to work on this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: endpointsenhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions