Steeltoe icon indicating copy to clipboard operation
Steeltoe copied to clipboard

InvalidOperationException for a configuration mistake is it too much?

Open sintetico82 opened this issue 3 years ago • 4 comments

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?

sintetico82 avatar Mar 03 '22 09:03 sintetico82

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?

TimHess avatar Mar 31 '22 20:03 TimHess

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.

sintetico82 avatar Apr 21 '22 09:04 sintetico82

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.

thompson-tomo avatar Feb 10 '24 03:02 thompson-tomo

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.

TimHess avatar Feb 10 '24 21:02 TimHess

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

bart-vmware avatar Mar 14 '24 14:03 bart-vmware