-
Notifications
You must be signed in to change notification settings - Fork 2k
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
^1.6: Unsupported Config Type "" when config file not found and falling back to extension-less filename #818
Comments
@andig unfortunately I cannot reproduce the issue with your code sample. I tried to simplify it a little bit:
But I'm unable to reproduce it with 1.6.0 and 1.6.1. There was indeed a breaking change introduced in 1.6.0, which the above code sample causes to return Please try to provide a breaking test, or a simple code sample that reproduces the issue. It might have environmental components (eg. existing file/directory, envorinment variable, etc), so please take those into account as well (eg. what config file are you trying to read? is there a directory with the same name?, etc). |
@andig any chance you can provide an example reproducing this bug? |
Will do but need some time for debugging to find the faulty case. |
Closing this one. I have the sneaking suspicion that I had a cobra |
No worries :) |
I've finally found what happens and why I didn't see it every time: Problem ist das in
|
Hey @andig thanks for the heads up. I'm curious: why is there a file with the same name as the config file but with no extension? Why not just name it something different or give it a meaningful extension? You also say the file exists during dev, this suggests it doesn't always exist, if so, wouldn't it be better to be in a build directory that would be clean every now and then? Having a config file without an extension is something that happens quite alot. I don't agree that it should be |
Thanks @pedromss for joining. Please let me start by reiterating the issue I perceive: With 1.6, untyped config files will be accepted by default. Unprepared applications, i.e. those that don't set a config type, will experience this as breaking change if such a file- for whatever reasons- exists in any of the search paths.
My app is specifically using yaml config (with extension). It comes bundled as
Sure. I still cannot control if such a file- that I'd really like to ignore- might not exist anywhere in the search path, especially if that includes user home dir or similar.
I accept that. I do not want this to impact my application though, especially when I have
This is not about parsing. It is rather about treating arbitrary files as config which- as with etcd- needs special preparation on the application side like setting config type. So... maybe one way to do this could be using |
Well, it's not arbitrary, you gave it a name to look for. But I understand how it might be a problem. Since setting a config type for extensionless files is required anyway, do you think @pedromss that we could restrict the search to only check extensionless files if there is a config type set? It's kind of a compromise solution: if you set a config type @andig Viper will find and try to parse those files. |
Sounds really reasonable and especially consistent with 1.5 behaviour to me. If this is the way forward it would be great to cut a point release asap. |
@sagikazarmark sounds ok to me. Should I get on it? |
1.6.0 has introduced a breaking change that will lead to failure if not config file is found. I used to do this:
Starting with 1.6.0,
viper.ReadInConfig
will returnif the config file does not exist. This is highly confusing as it should really be
ConfigFileNotFoundError
instead ofUnsupportedConfigError
. Please advise.The text was updated successfully, but these errors were encountered: