Skip to content

Error responses contain strange indexes #1434

Closed
@renra

Description

@renra

Hello,

I have the following grape endpoint:

params do
  requires :user, type: Hash do
    requires :access_start, type: Date, allow_blank: false
    # ... more required attributes
  end

  require :filters, type: Array
end

When I send the following data: {"user":{"access_start": null},"filters":[{"id":{"equals":[1, 2]}}]} and I inspect the error raised by grape(calling as_json on it), I sometimes get errors like this:

[{:params=>["user[access_start]"], :messages=>["is empty"]}]

and sometimes like this:

[{:params=>["user[0][access_start]"], :messages=>["is empty"]}]

I am not able to get a consistent behaviour, but the first way seems correct to me. Using grape 0.16.2

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions