Skip to content
This repository was archived by the owner on Aug 9, 2025. It is now read-only.
This repository was archived by the owner on Aug 9, 2025. It is now read-only.

Validation Exception Metadata #554

@justinsaliba

Description

@justinsaliba

Hi,

I'd like to request a small feature that would allow Mule APIs to return more verbose and helpful responses to API consumers.

I would like to request that APIKit exceptions would contain metadata about why validation failed. Currently, there is a simple error message, which works fine as an API response, however that's about as far as developers can take it. To give you an example, here's the exception message thrown by APIKit when query parameter validation fails:

org.mule.module.apikit.api.exception.InvalidQueryParameterException: Invalid value '2020-08-011' for query parameter flightDate. [2020-08-011] is not a valid date. Expected [yyyy-MM-dd]

As a result, we can wrap this message in a nice JSON response coupled with an HTTP 400 response code:

{
  "message": "Invalid value '2020-08-011' for query parameter flightDate. [2020-08-011] is not a valid date. Expected [yyyy-MM-dd]"
}

My request here is to expand this to something like this:

{
  "message": "Invalid value '2020-08-011' for query parameter flightDate. [2020-08-011] is not a valid date. Expected [yyyy-MM-dd]",
  "field": "flightDate",
  "errorValue": "2020-08-011"
}

I guess this can be achieved by passing in the erroneous parameters and metadata when constructing the InvalidQueryParameterException (or any other APIKit validation exceptions).

A workaround to this would be to define regular expressions around APIKit error messages but that's an extremely brittle solution since error messages might change (as they did in APIKit 3.8 --> APIKit 3.9)

Thanks,
Justin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions