Skip to content

Bools: return the matched []bool, not the nil intermediate#416

Merged
knadh merged 1 commit into
knadh:masterfrom
c-tonneslan:fix/bools-nil-return-on-bool-slice
May 28, 2026
Merged

Bools: return the matched []bool, not the nil intermediate#416
knadh merged 1 commit into
knadh:masterfrom
c-tonneslan:fix/bools-nil-return-on-bool-slice

Conversation

@c-tonneslan
Copy link
Copy Markdown
Contributor

Spotted while reading getters.go. The Bools() type switch has

case []bool:
    return out

but out is the var out []bool declared above and only filled by the []any branch, so on a value stored natively as a []bool (e.g. via the confmap provider) Bools() returns nil. Mirrors what Ints, Int64s, and Float64s already do for their native-type cases (they return v).

Added a tiny regression test in koanf_test.go using the confmap provider; it fails on master with <nil> vs the expected []bool{true, false, true}.

The []bool case in the type switch returned out, which is the locally
declared var out []bool that's only filled by the []any branch. So
Bools("key") on a value stored natively as []bool returned nil,
matching the docstring's empty-slice intent only by accident on the
unknown-type fall-through (which actually returns nil too).

Mirrors what Ints, Int64s, and Float64s already do for their native-type
cases.

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
@knadh knadh force-pushed the fix/bools-nil-return-on-bool-slice branch from 849f0a9 to a064082 Compare May 28, 2026 07:26
@knadh knadh merged commit 2dd78e8 into knadh:master May 28, 2026
4 checks passed
Maks1mS pushed a commit to stplr-dev/stplr that referenced this pull request May 30, 2026
This PR contains the following updates:

| Package | Type | Update | Change | OpenSSF |
|---|---|---|---|---|
| [github.com/knadh/koanf/v2](https://github.com/knadh/koanf) | require | patch | `v2.3.4` → `v2.3.5` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/knadh/koanf/badge)](https://securityscorecards.dev/viewer/?uri=github.com/knadh/koanf) |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/23) for more information.

---

### Release Notes

<details>
<summary>knadh/koanf (github.com/knadh/koanf/v2)</summary>

### [`v2.3.5`](https://github.com/knadh/koanf/releases/tag/v2.3.5)

[Compare Source](knadh/koanf@v2.3.4...v2.3.5)

#### What's Changed

- go-toml v3.3.0 by [@&#8203;GreyXor](https://github.com/GreyXor) in [#&#8203;410](knadh/koanf#410)
- Bump github.com/go-jose/go-jose/v4 from 4.1.0 to 4.1.4 in /providers/vault by [@&#8203;dependabot](https://github.com/dependabot)\[bot] in [#&#8203;411](knadh/koanf#411)
- go-toml v2.3.1 by [@&#8203;GreyXor](https://github.com/GreyXor) in [#&#8203;414](knadh/koanf#414)
- feat: Add k8smount provider by [@&#8203;mattdowdell](https://github.com/mattdowdell) in [#&#8203;409](knadh/koanf#409)
- Bools: return the matched \[]bool, not the nil intermediate by [@&#8203;c-tonneslan](https://github.com/c-tonneslan) in [#&#8203;416](knadh/koanf#416)
- fix: report the full key path in MergeStrict type-mismatch error by [@&#8203;koriyoshi2041](https://github.com/koriyoshi2041) in [#&#8203;418](knadh/koanf#418)

#### New Contributors

- [@&#8203;mattdowdell](https://github.com/mattdowdell) made their first contribution in [#&#8203;409](knadh/koanf#409)
- [@&#8203;c-tonneslan](https://github.com/c-tonneslan) made their first contribution in [#&#8203;416](knadh/koanf#416)
- [@&#8203;koriyoshi2041](https://github.com/koriyoshi2041) made their first contribution in [#&#8203;418](knadh/koanf#418)

**Full Changelog**: <knadh/koanf@v2.3.4...v2.3.5>

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At 12:00 AM through 04:59 AM and 10:00 PM through 11:59 PM, Monday through Friday (`* 0-4,22-23 * * 1-5`)
  - Only on Sunday and Saturday (`* * * * 0,6`)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTUuMyIsInVwZGF0ZWRJblZlciI6IjQzLjE5NS4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJLaW5kL0RlcGVuZGVuY2llcyJdfQ==-->

Reviewed-on: https://altlinux.space/stapler/stplr/pulls/445
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