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

Deserialization exceptions #1745

Closed
3 tasks done
bystart opened this issue Jan 31, 2024 · 3 comments
Closed
3 tasks done

Deserialization exceptions #1745

bystart opened this issue Jan 31, 2024 · 3 comments
Labels
kind/support Support requests for using the project

Comments

@bystart
Copy link

bystart commented Jan 31, 2024

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.16

Go Version

1.21.1

Config Source

Defaults

Format

No response

Repl.it link

No response

Code reproducing the issue

type ApplicationConfig struct {
	appName string `yaml:"appName"`
	Version string `yaml:"version"`
}
type DBConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type RedisConfig struct {
	Host string `yaml:"host"`
	Port int    `yaml:"port"`
}

type AppConfig struct {
	ApplicationConfig ApplicationConfig `yaml:"application"`
	DB                DBConfig          `yaml:"db"`
	Redis             RedisConfig       `yaml:"redis"`
}
--------------

Expected Behavior

The ApplicationConfig field property cannot be serialized

Actual Behavior

The ApplicationConfig field property cannot be serialized

Steps To Reproduce

No response

Additional Information

image

@bystart bystart added the kind/bug Something isn't working label Jan 31, 2024
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! ❤️

@bystart
Copy link
Author

bystart commented Jan 31, 2024

type ApplicationConfig struct {
AppName string yaml:"appName"
Version string yaml:"version"
}
type DBConfig struct {
Host string yaml:"host"
Port int yaml:"port"
Username string yaml:"username"
Password string yaml:"password"
}

type RedisConfig struct {
Host string yaml:"host"
Port int yaml:"port"
}

type AppConfig struct {
ApplicationConfig ApplicationConfig yaml:"application"
DB DBConfig yaml:"db"
Redis RedisConfig yaml:"redis"
}

@sagikazarmark sagikazarmark added kind/support Support requests for using the project and removed kind/bug Something isn't working labels Jan 31, 2024
@sagikazarmark
Copy link
Collaborator

No idea how your other values get set, but my guess is they come from some defaults.

https://github.com/spf13/viper/blob/master/TROUBLESHOOTING.md#unmarshaling-doesnt-work

https://github.com/spf13/viper#unmarshaling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Support requests for using the project
Projects
None yet
Development

No branches or pull requests

2 participants