luckyframework / lucky

A full-featured Crystal web framework that catches bugs for you, runs incredibly fast, and helps you write code that lasts.
https://luckyframework.org
MIT License
2.57k stars 156 forks source link

Expected Hash for #[]?(key : String), not Array(JSON::Any) #1897

Open jwoertink opened 4 weeks ago

jwoertink commented 4 weeks ago

I don't have a ton of info about this, but I started getting it a ton on my app, and the stacktrace all points to Lucky.

I think this might be related to having query params defined on a POST. I'll come back to this later but I want to track it for now.

class Reporting::Track < ApiAction
  param env : String
  param host : String

  post "/reporting/track" do
    json({env: env, host: host})
  end
end 
Exception Expected Hash for #[]?(key : String), not Array(JSON::Any) 
    /home/runner/work/_temp/crystal-1.12.1-true-undefined/share/crystal/src/json/any.cr:129:7 in '??' <file>
    /home/runner/work/joysticktv/joysticktv/lib/lucky/src/lucky/params.cr:576:7 in 'body_param' <file>
    /home/runner/work/joysticktv/joysticktv/lib/lucky/src/lucky/params.cr:141:5 in 'get_raw?' <file>
    /home/runner/work/joysticktv/joysticktv/lib/lucky/src/lucky/params.cr:114:8 in 'host' <file>