Repository: spf13/viper

Issue #1431: with 1.13.0, breaking change has been introduced on yaml
Created: 2022-09-08T08:35:17Z
Preflight Checklist

 I have searched the issue tracker for an issue that matches the one I want to file, without success.
 I am not looking for support or already pursued the available support channels without success.
 I have checked the troubleshooting guide for my problem, without success.

Viper Version
1.13.0
Go Version
1.19
Config Source
Defaults
Format
YAML
Repl.it link
No response
Code reproducing the issue
package main

import (
	"fmt"

	"github.com/spf13/viper"
)

func main() {
	v := viper.New()
	v.AddConfigPath(".")
	v.SetConfigName("conf")
	if err := v.ReadInConfig(); err != nil {
		panic(err)
	}

	var seq []seq
	if err := v.Unmarshal(&seq); err != nil {
		panic(err)
	}

	fmt.Println(seq)
}

type value struct {
	Bool bool `mapstructure:"bool"`
}

type Map map[string]value

type seq struct {
	List []Conf `mapstructure:"list"`
}

type Conf struct {
	Config Map `mapstructure:"conf"`
}
with config :
list:
- conf:
    FR:
      Bool: false
- conf:
    FR:
      Bool: true
    EN:
      Bool: false
Expected Behavior
with 1.12.0, seq equals [{[{map[FR:{false}]} {map[EN:{false} FR:{true}]}]}]
with 1.13.0, seq equals [{[{map[fr:{false}]} {map[en:{false} fr:{true}]}]}]
Actual Behavior
expected we have the same case FR not fr for the key map
Steps To Reproduce
No response
Additional Information
No response

Duplicate issue #1486: unexpected lowercasing of keys of map[string]interface{} in viper >= 1.13.0
Created: 2023-01-10T14:21:50Z
Preflight Checklist

 I have searched the issue tracker for an issue that matches the one I want to file, without success.
 I am not looking for support or already pursued the available support channels without success.
 I have checked the troubleshooting guide for my problem, without success.

Viper Version
1.13.0
Go Version
1.19
Config Source
Files
Format
YAML
Repl.it link
No response
Code reproducing the issue
package main

import (
	"fmt"
	"github.com/spf13/viper"
)

/* My pkg/config/testdata/config.yaml:
resources:
- name: resourceQuota
  config:
    limitsMemory: "48Gi"
    requestsMemory: "24Gi"
    requestsCpu: "10"
*/
type Config struct {
	Resources []Resource `yaml:"resources"`
}
type Resource struct {
	Name   string                 `yaml:"name"`
	Config map[string]interface{} `yaml:"config"`
}

func main() {
	viper.AddConfigPath("pkg/config/testdata")
	viper.SetConfigType("yaml")
	viper.SetConfigName("config")
	viper.ReadInConfig()
	readConf := &Config{}
	viper.Unmarshal(readConf)
	fmt.Println(readConf)
}
Expected Behavior
&{[{resourceQuota map[limitsMemory:48Gi requestsCpu:10 requestsMemory:24Gi]}]}
Actual Behavior
&{[{resourceQuota map[limitsmemory:48Gi requestscpu:10 requestsmemory:24Gi]}]}
Steps To Reproduce
No response
Additional Information
Behaviour is reproducible for Viper >= 1.13.0

Closing comment (2023-01-10T15:03:59Z): This change was introduced in #1387 as a bug fix. Unfortunately, the behavior so far was the result of a bug that was fixed in that PR (Viper does not support case-sensitivity at the moment).
Prior to this fix Viper would not make keys case-insensitive in slices.
Duplicate of #1431