fix: regression that replaces an unknown media type with */* (#4013)

This commit is contained in:
Taimoor Zaeem
2025-04-14 09:57:54 -05:00
committed by GitHub
parent a1009d1bae
commit feb5b7d494
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -155,7 +155,7 @@ decodeMediaType mt = decodeMediaType' $ decodeLatin1 mt
mediaTypeOrError = P.parse tokenizeMediaType "parsec: tokenizeMediaType failed" $ T.unpack mt'
(mainType, subType, params') = case mediaTypeOrError of
Right mt'' -> mt''
Left _ -> ("*", "*", []) -- TODO: Throw mediatype error, would need refactoring because currently Error module depend on MediaType module
Left _ -> (mt',"",[])
params = fromList $ map (first T.toLower) params' -- normalize parameter names to lowercase, per RFC 7321
getPlan fmt = MTVndPlan mtFor fmt $
[PlanAnalyze | inOpts "analyze" ] ++
@@ -375,3 +375,10 @@ spec = describe "custom media types" $ do
{ matchStatus = 200
, matchHeaders = ["Content-Type" <:> "application/octet-stream"]
}
context "media type parser fails" $ do
it "sends media type as is" $
request methodGet "/items" (acceptHdrs "undefined") ""
`shouldRespondWith`
[json| {"code":"PGRST107","details":null,"hint":null,"message":"None of these media types are available: undefined"} |]
{ matchStatus = 406 }