JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

500 error when including relationship name in attributes hash

Open
#697 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

Say I have a record post that has_one author... Including author in the attributes hash instead of the relationships hash causes jsonapi-resources to 500 with the following:

Internal Server Error: no implicit conversion of nil into Hash /Users/adam/.rvm/gems/ruby-2.2.3/gems/jsonapi-resources-0.7.0/lib/jsonapi/resource.rb:683:in `merge'

My guess is because this is a valid relationship name, but is not a valid attribute.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using a resource with a has_one author relationship and author supplied in the attributes hash. Start at lib/jsonapi/resource.rb:683 and trace the merge inputs; done means this invalid placement no longer causes a 500, with the expected handling covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.