lucky icon indicating copy to clipboard operation
lucky copied to clipboard

Params should not raise on empty many_nested? params when key is present

Open jwoertink opened this issue 6 months ago • 2 comments

Similar to https://github.com/luckyframework/lucky/issues/1949 I have params that look like this:

{menu: {}, items: [{....}]}

These params get passed in to an operation like

SaveMenuAndItems.update!(menu, params)

In this case, I'm only concerned about the items. I'm not looking to update menu, but I do include the key just with an empty param body. In this case, it will still raise Lucky::MissingNestedParamError. We should allow this and only raise if params is missing the key completely. (e.g. {items: []} .

I think this comes from here...

https://github.com/luckyframework/lucky/blob/7787f99baa8e7b8f6522fb427c9f19ef49137b05/src/lucky/params.cr#L542

jwoertink avatar Jun 16 '25 20:06 jwoertink

Yeah, it should not raise. Can you post a stack trace? Where and how are you calling #many_nested?, since operations do not currently auto extract those from params?

akadusei avatar Jun 17 '25 09:06 akadusei

I don't have a stack trace. I wasn't really getting this error specifcally. I was just getting the error that says "Missing key ...." even though it wasn't "missing". I was passing in the menu key with empty params, and the items key with the data I cared about but still got the "Missing key :menu` error. I'll have to try and get that branch going again so I can get a better code example and stacktrace.

jwoertink avatar Jun 17 '25 16:06 jwoertink