JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Filter on a boolean field is applied as a string

Open
#852 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I am seeing the following behavior in my application

Started GET "/jsonapi/v1/tasks?filter%5Bis-complete%5D=false" for xx.xx.xx.xx at <time snipped>
Cannot render console from xx.xx.xx.xx! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Jsonapi::V1::TasksController#index as API_JSON
  Parameters: {"filter"=>{"is-complete"=>"false"}}

The "is-complete" field is defined as a boolean in my model. Regular GET requests work fine as a boolean value is sent from the backend.

Is this expected?

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

Start at Jsonapi::V1::TasksController#index and trace how the filter[is-complete] parameter reaches the resource or model; inspect the handling of the boolean field. Reproduce the request and add or update a focused test so the false value is handled consistently with the model's boolean type, then verify the expected API behavior.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.