Skip to content

fix: report the full key path in MergeStrict type-mismatch error#418

Merged
knadh merged 1 commit into
knadh:masterfrom
koriyoshi2041:fix/mergestrict-error-key
May 30, 2026
Merged

fix: report the full key path in MergeStrict type-mismatch error#418
knadh merged 1 commit into
knadh:masterfrom
koriyoshi2041:fix/mergestrict-error-key

Conversation

@koriyoshi2041
Copy link
Copy Markdown
Contributor

mergeStrict (maps/maps.go) builds newFullKey, the full dotted path to the key currently being merged, and passes it to the recursive call. But the type-mismatch error reports the parent fullKey instead:

return fmt.Errorf("incorrect types at key %v, type %T != %T", fullKey, b[key], val)

So the error names the wrong key:

  • A top-level type conflict has fullKey == "", producing incorrect types at key , type int != string (blank key name).
  • A nested conflict reports the enclosing map path and drops the actual conflicting leaf, e.g. parent.child instead of parent.child.key.

This is reachable from public API via MergeStrict and Koanf.Load with Conf{StrictMerge: true}. The fix uses newFullKey, matching what the recursive call already uses.

Added TestMergeStrictErrorKey in tests/maps_test.go asserting the error names the full path for both a top-level and a nested conflict (the existing TestMergeStrict only checked that an error occurred, not its contents). go test passes.

mergeStrict computes newFullKey (the full dotted path to the current key) and
uses it for the recursive call, but the type-mismatch error reported the
parent fullKey instead. A top-level conflict therefore showed an empty key
name ("incorrect types at key , ...") and a nested conflict dropped the
leaf key. Use newFullKey so the error names the actual conflicting key.
@knadh knadh merged commit e09e4c8 into knadh:master May 30, 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