-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Description
I'm running the latest versions of the Graphiti toolkit on Rails 6.2 and I'm unable to create a new record with my API, given valid attributes. An error is thrown when there are no validation errors like so:
#<NoMethodError: undefined method `[]' for nil:NilClass>which points to like 42 in this file https://github.com/graphiti-api/graphiti_errors/blob/master/lib/graphiti_errors/validation/serializer.rb
details = if Rails::VERSION::MAJOR >= 5
object.errors.details.find { |k, v| k == attribute }[1]
endWhen there are validation errors, the NoMethodError is not thrown. Only when the record is valid.
Request:
POST localhost:3000/api/v1/accounts
{
"data": {
"type": "accounts",
"attributes": {
"name": "Savings Account",
"account_type": "savings",
"currency": "eur"
}
}
}Response:
"meta": {
"__details__": {
"exception": "#<NoMethodError: undefined method `[]' for nil:NilClass>",
"traces": {
"Application Trace": [
{
"exception_object_id": 70175924115520,
"id": 24,
"trace": "app/controllers/accounts_controller.rb:20:in `create'"
}
],
"Framework Trace": [
{
"exception_object_id": 70175924115520,
"id": 0,
"trace": "graphiti_errors (1.1.1) lib/graphiti_errors/validation/serializer.rb:42:in `block in each_error'"
},
//... irrelevant back trace
]
}
Metadata
Metadata
Assignees
Labels
No labels