interagent / interagent/committee
JSON body interaction
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 955
- Forks
- 145
- Avg merge
- 5d 4h
- Merged PRs (30d)
- 6
Description
Hey!
I have an issue that I think it's on committee's side, but I'm not sure.
So, I'm using Grape for my API, with rodauth+rodauth-oauth for the auth part.
Here's the issue: with grape reading the body, committee works fine. It seems grape rewinds the body before and after reading it, so it's ready for committee:
https://github.com/ruby-grape/grape/blob/master/lib/grape/middleware/formatter.rb#L86-L92
However, Roda doesn't if rack is >=3. https://github.com/jeremyevans/roda/blob/master/lib/roda/plugins/json_parser.rb#L89-L93
Now, the issue is that since committee does not rewind ahead of reading, it gets an empty body and assumes the lenght == 0 situation (and therefore, no params) and fails the validation: https://github.com/interagent/committee/blob/master/lib/committee/request_unpacker.rb#L81-L83
Adding a rewind before reading solves the issue, but I'm not sure it's the right way to go (I read the Rack spec but it's not clear to me if that rewind is meant to always work).
I thought I could take the grape route and rewind if the input responds to rewind (see #442), wdyt?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/committee/request_unpacker.rb around lines 81-83 and compare its body-reading behavior with the Roda JSON parser and Grape formatter links in the issue. Review the Rack body-rewind expectations for Rack 3. Done means JSON request parameters from the Roda/Rack setup are available to Committee and validation no longer treats a readable body as empty.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- 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