Skip to content

bug(fxconfig): config validation for NotificationsConfig does not call EndpointServiceConfig.Validate #254

Description

@ARYANPATEL-BIT

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:

  1. Delegate to the embedded EndpointServiceConfig.Validate() to validate shared fields.
  2. 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

  1. Configure fxconfig with a NotificationsConfig where waitingTimeout is set to -1s or 0s.
  2. Run the application. The validation phase passes without errors.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions