luckyframework / luckyframework/lucky

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

Open
#1,968 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Crystal
Stars
2.7k
Forks
172
PR merge metrics
No merged PRs in 30d

Description

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

```crystal
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

Contributor guide

Open the contributing guide

Research direction

Start in src/lucky/params.cr around line 542, where the issue identifies the nested-parameter validation. Reproduce the examples with an empty menu and populated items, then verify that an explicitly empty nested key is accepted while a missing key still raises Lucky::MissingNestedParamError.

Written by the indexing model from the issue text.

Assessment

Tech stack
crystal
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.