luckyframework / luckyframework/lucky
Expected Hash for #[]?(key : String), not Array(JSON::Any)
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 2.7k
- Forks
- 172
- PR merge metrics
- No merged PRs in 30d
Description
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>
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 in lib/lucky/src/lucky/params.cr, especially the body_param and get_raw? locations shown in the stack trace. Reproduce the Reporting::Track action with env and host parameters and a POST request, then determine why the JSON value is treated as an array instead of a hash. Done means the reported exception no longer occurs for this case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100