Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message have a blank value in the pointer field for model attributes with a underscore #56

Open
bsylvain opened this issue Aug 3, 2021 · 3 comments · May be fixed by #58
Open
Milestone

Comments

@bsylvain
Copy link

bsylvain commented Aug 3, 2021

Expected Behavior

When there is a validation error to return a json error with pointer filed for attributes with an underscore

Actual Behavior

The JSON:API error message has a blank pointer value in the error payload when the attribute contain a underscore

Steps to Reproduce the Problem

Create a model with a field that contain a underscore. Set the serializer to set_key_transform :dash
Send an update or a create that violate a validation on the field of the underscore
The json error pointer value is empty

Specifications

  • Version: 1.6
  • Ruby version: 2.5
@bsylvain
Copy link
Author

bsylvain commented Aug 3, 2021

Ok so I found a way to monkeypatch my problem. I replaced this line :

attrs = (model_serializer.attributes_to_serialize || {}).keys

with this :
attrs = (model_serializer.attributes_to_serialize || {}).keys.map{|k| k.to_s.underscore.to_sym}

It's ugly, but it's the only way i found to respect JSONAPI and still get errors for field with _ in it.

@stas stas linked a pull request Aug 4, 2021 that will close this issue
3 tasks
@stas stas added this to the v1.8 milestone Sep 1, 2021
@storm-factory
Copy link

storm-factory commented Jul 27, 2022

This isn't fixed in v2.0.0, looks like v1.8 never happened?

I'm running into the same issue

@stas
Copy link
Owner

stas commented Aug 30, 2022

We had to skip over v1.8 because of the breaking changes. Btw, there's #58, nobody weighted on the changes there so it probably got lost.

We can have a small release with this one. @storm-factory did #58 solve your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants