Description
In tools/fxconfig/internal/config/config.go, both NotificationsConfig and QueriesConfig embed EndpointServiceConfig via mapstructure:",squash" but neither of them implement their own Validate() method.
Because they lack a Validate() method, when Provider.Get() calls p.cfg.Validate() (in provider.go), it silently falls back to calling the embedded EndpointServiceConfig.Validate().
While this validates the embedded fields, it completely skips validating the struct-specific fields. For example, NotificationsConfig has an additional WaitingTimeout field. Because this field is never validated, a user can set waitingTimeout: 0s or a negative value, and the configuration will silently accept it. This can result in the notification client being configured with invalid timeouts, leading to immediate transaction waiting failures.
Expected Behavior
NotificationsConfig and QueriesConfig should have their own explicit Validate(v validation.Context) error methods that:
- Delegate to the embedded
EndpointServiceConfig.Validate() to validate shared fields.
- Validate their own specific fields (e.g., ensuring
WaitingTimeout is a positive duration within a reasonable upper bound, like max 10 minutes).
Steps to Reproduce
- Configure
fxconfig with a NotificationsConfig where waitingTimeout is set to -1s or 0s.
- Run the application. The validation phase passes without errors.
- The notification client receives an invalid timeout parameter, leading to unexpected failures during transaction waiting.
Proposed Solution
Add explicit Validate methods for NotificationsConfig and QueriesConfig inside tools/fxconfig/internal/config/validate.go. Add unit tests ensuring that negative or excessively large duration values are correctly rejected.
Description
In
tools/fxconfig/internal/config/config.go, bothNotificationsConfigandQueriesConfigembedEndpointServiceConfigviamapstructure:",squash"but neither of them implement their ownValidate()method.Because they lack a
Validate()method, whenProvider.Get()callsp.cfg.Validate()(inprovider.go), it silently falls back to calling the embeddedEndpointServiceConfig.Validate().While this validates the embedded fields, it completely skips validating the struct-specific fields. For example,
NotificationsConfighas an additionalWaitingTimeoutfield. Because this field is never validated, a user can setwaitingTimeout: 0sor a negative value, and the configuration will silently accept it. This can result in the notification client being configured with invalid timeouts, leading to immediate transaction waiting failures.Expected Behavior
NotificationsConfigandQueriesConfigshould have their own explicitValidate(v validation.Context) errormethods that:EndpointServiceConfig.Validate()to validate shared fields.WaitingTimeoutis a positive duration within a reasonable upper bound, like max 10 minutes).Steps to Reproduce
fxconfigwith aNotificationsConfigwherewaitingTimeoutis set to-1sor0s.Proposed Solution
Add explicit
Validatemethods forNotificationsConfigandQueriesConfiginsidetools/fxconfig/internal/config/validate.go. Add unit tests ensuring that negative or excessively large duration values are correctly rejected.