Steeltoe
Steeltoe copied to clipboard
InvalidOperationException for a configuration mistake is it too much?
https://github.com/SteeltoeOSS/Steeltoe/blob/8e9686587844f86b40135cbe73d6d193f0c4bcb5/src/Discovery/src/Consul/ConsulPostConfigurer.cs#L24
In my opinion, avoid to start an application in a container only for a miss configuration for service discovery is too much. Why don't just write a critical error log?
Sorry for the super delayed response, I thought I replied to this already. The intent here was a fast failure on what was seen as something that could only be a misconfiguration that is likely critical to the success of the application.
You're not wrong, it is a bit extreme. Do you have a scenario where the app is likely to run successfully with this configuration?
Sorry for the delayed answer too.
I catch this in error in the development environment. I think in some multiple purpose scenarios, where some services can be also optional (for developing reasons, for the available chain, or other factors).
In my opinion, let the use of framework more flexible could be a better option, but of course, it's a questionable opinion.
As a thought, could we extend the configure options with an enabled flag which if false doesn't result in the exception. I note the logic is in static class & the Eureka implementation is very similar except it has the enabled flag.
Thank you for that thought - I should note that @bart-vmware is in the middle of a comprehensive API review and some potentially significant re-work of the entire service discovery component (ahead of working with Aspire), so he would be in a better position to comment here, and it would be prudent to check with him before attempting any changes to discovery in main.
We've had some internal discussion and believe it's best to follow ASP.NET conventions here, which is implementing IValidateOptions, which throws OptionsValidationException when the configuration is invalid. This helps to catch mistakes early, instead of silently ignoring what's configured (assuming not everyone is watching the logs all the time).