Skip to content

Commit 924bff9

Browse files
stasadevndeloof
authored andcommitted
fix: prevent panic on empty key
Signed-off-by: Stanislav Zhuk <[email protected]>
1 parent 5f04daa commit 924bff9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

types/mapping.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (m *MappingWithEquals) DecodeMapstructure(value interface{}) error {
9595
mapping := make(MappingWithEquals, len(v))
9696
for _, s := range v {
9797
k, e, ok := strings.Cut(fmt.Sprint(s), "=")
98-
if unicode.IsSpace(rune(k[len(k)-1])) {
98+
if k != "" && unicode.IsSpace(rune(k[len(k)-1])) {
9999
return fmt.Errorf("environment variable %s is declared with a trailing space", k)
100100
}
101101
if !ok {

0 commit comments

Comments
 (0)