hyperledger / hyperledger/fabric-x

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

Open
#254 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
64
Forks
80
Avg merge
1d 22h
Merged PRs (30d)
15

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.