You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I make a call to retrieve a model from an api. The call fails validation and returns a 422 (Unprocessable Entity). The body of the response is an array of arrays, with key value pairs for the attribute and associated error:
[["username", "has already been taken"]]
It's ugly and her/model/orm.rb throws a "no implicit conversion of Symbol into Integer" exception. Which I get, but the above constrruct was generated by Active Record (albeit rails 1.4).
I can create a hash of those kv pairs, but then, Her merely assigns them as valid attributes and my controller receives a valid 200 response. What happened to the error status? Is there any hidden documentation about how Her handles error responses?
The text was updated successfully, but these errors were encountered:
Hi @eggmatters. Which middleware are you using to parse the responses you get back from the API you're calling? Based on your description of the behavior, I'd guess you're using Her::Middleware::FirstLevelParseJSON (same as DefaultParseJSON).
If that's the case, Her will expect a hash of the model's attributes at the top level, including errors. so something like:
I make a call to retrieve a model from an api. The call fails validation and returns a 422 (Unprocessable Entity). The body of the response is an array of arrays, with key value pairs for the attribute and associated error:
It's ugly and her/model/orm.rb throws a "no implicit conversion of Symbol into Integer" exception. Which I get, but the above constrruct was generated by Active Record (albeit rails 1.4).
I can create a hash of those kv pairs, but then, Her merely assigns them as valid attributes and my controller receives a valid 200 response. What happened to the error status? Is there any hidden documentation about how Her handles error responses?
The text was updated successfully, but these errors were encountered: