ring-clojure / ring-clojure/ring
Request contains nil :body and :query-string
Nobody has claimed this yet.
- Dominant language
- Clojure
- Stars
- 3.9k
- Forks
- 528
- PR merge metrics
- No merged PRs in 30d
Description
I've tried using both jetty and httpkit, in both cases my request maps contain nil values for the optional keys :body and :query-string; this is not compliant with the :ring/request spec. Is it possible to remove the keys from the request map instead of setting them to nil in order to remain spec compliant?
Call to #'hanabi.web/initialise did not conform to spec:
web.clj:181
-- Spec failed --------------------
Function arguments
({:reitit.core/match ...,
:reitit.core/router ...,
:remote-addr ...,
:params ...,
:headers ...,
:async-channel ...,
:server-port ...,
:content-length ...,
:form-params ...,
:websocket? ...,
:web/session ...,
:query-params ...,
:content-type ...,
:character-encoding ...,
:uri ...,
:server-name ...,
:query-string ...,
:path-params ...,
:body nil,
^^^
:scheme ...,
:request-method ...})
should satisfy
#object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x765709fc "clojure.spec.alpha$regex_spec_impl$reify__2436@765709fc"]
-- Relevant specs -------
:ring.request/body:
:clojure.spec.alpha/unknown
:ring/request:
(clojure.spec.alpha/keys
:req-un
[:ring.request/server-port
:ring.request/server-name
:ring.request/remote-addr
:ring.request/uri
:ring.request/scheme
:ring.request/protocol
:ring.request/headers
:ring.request/request-method]
:opt-un
[:ring.request/query-string :ring.request/body])
:web.ring/request:
(clojure.spec.alpha/merge
:ring/request
(clojure.spec.alpha/keys
:req
[:web/session]
:req-un
[:web.ring.request/edn-params]))
-- Spec failed --------------------
Function arguments
({:reitit.core/match ...,
:reitit.core/router ...,
:remote-addr ...,
:params ...,
:headers ...,
:async-channel ...,
:server-port ...,
:content-length ...,
:form-params ...,
:websocket? ...,
:web/session ...,
:query-params ...,
:content-type ...,
:character-encoding ...,
:uri ...,
:server-name ...,
:query-string nil,
^^^
:path-params ...,
:body ...,
:scheme ...,
:request-method ...})
should satisfy
#object[clojure.spec.alpha$regex_spec_impl$reify__2436 0x765709fc "clojure.spec.alpha$regex_spec_impl$reify__2436@765709fc"]
-- Relevant specs -------
:ring.request/query-string:
:clojure.spec.alpha/unknown
:ring/request:
(clojure.spec.alpha/keys
:req-un
[:ring.request/server-port
:ring.request/server-name
:ring.request/remote-addr
:ring.request/uri
:ring.request/scheme
:ring.request/protocol
:ring.request/headers
:ring.request/request-method]
:opt-un
[:ring.request/query-string :ring.request/body])
:web.ring/request:
(clojure.spec.alpha/merge
:ring/request
(clojure.spec.alpha/keys
:req
[:web/session]
:req-un
[:web.ring.request/edn-params]))
-------------------------
Detected 2 errors
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 at web.clj:181 and inspect how requests from Jetty and http-kit are assembled, then compare those maps with the linked :ring/request spec. Reproduce the two spec failures and verify that optional :body and :query-string handling no longer violates the spec.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100