Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected lowercasing of keys of map[string]interface{} in viper >= 1.13.0 #1486

Closed
3 tasks done
deynekas opened this issue Jan 10, 2023 · 5 comments
Closed
3 tasks done
Labels
kind/bug Something isn't working

Comments

@deynekas
Copy link

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

@deynekas deynekas added the kind/bug Something isn't working label Jan 10, 2023
@github-actions
Copy link

👋 Thanks for reporting!

A maintainer will take a look at your issue shortly. 👀

In the meantime: We are working on Viper v2 and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues.

⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9

📣 If you've already given us your feedback, you can still help by spreading the news,
either by sharing the above link or telling people about this on Twitter:

https://twitter.com/sagikazarmark/status/1306904078967074816

Thank you! ❤️

@sagikazarmark
Copy link
Collaborator

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

@deynekas
Copy link
Author

Thank you for clarification!

@qwackididuck
Copy link

Hello @sagikazarmark !

Since it's a recurrent issue and need, would you accept, if it existed, a PR that allows users to set a bool that will take in account the case sensitivity ?

Thanks !

Have a great day.

@deynekas deynekas closed this as not planned Won't fix, can't repro, duplicate, stale Jan 15, 2023
@sagikazarmark
Copy link
Collaborator

@b-repo @deynekas due to popular demand, I'm going to allow reverting back to the previous behavior using a go tag.

#1576

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants