Skip to content

Fix missing nested param error for nested array params#1085

Merged
jwoertink merged 3 commits intoluckyframework:mainfrom
akadusei:nested-param-error
Apr 28, 2025
Merged

Fix missing nested param error for nested array params#1085
jwoertink merged 3 commits intoluckyframework:mainfrom
akadusei:nested-param-error

Conversation

@akadusei
Copy link
Contributor

@akadusei akadusei commented Apr 27, 2025

Even if nested params is not empty, Lucky would still raise Lucky::MissingNestedParamError if any array attributes are not set.

You had to fill in the array attribute to avoid the error:

response = client.exec(Features::Create, feature: {
  choices: Array(String).new, # Without this, you get "Missing param key: 'feature' (Lucky::MissingNestedParamError)..."
  maximum: 99,
  minimum: 3,
  name: "Number of Kitchens",
  type: :integer
})

See luckyframework/lucky#1949

`Lucky::Params#nested_arrays?` returns a hash, which is truthy.
`Lucky::Params#nested_file?` returns a hash always, although its
signature says it returns a nilable hash.
Even if nested params is not empty, Lucky would still raise
`Lucky::MissingNestedParamError` if any array attributes are empty.

You had to fill in the array attribute to avoid the error:

```
response = client.exec(Features::Create, feature: {
  choices: Array(String).new, # Without this, you get "Missing param key: 'feature' (Lucky::MissingNestedParamError)..."
  maximum: 99,
  minimum: 3,
  name: "Number of Kitchens",
  type: :integer
})
```
Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jwoertink jwoertink merged commit f366c8d into luckyframework:main Apr 28, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants