From a3e142b53428f97813a8e373ec5631768d936305 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Tue, 21 Apr 2026 14:48:10 +0200 Subject: [PATCH] fix: only apply beaconapi.clientIndex filter when explicitly set ClientIndex was a plain `int` whose zero value (0) caused ReadConfig to collapse `beaconapi.endpoints` down to `endpoints[0]` whenever the field was omitted from the config. Users with multiple beacon endpoints only ever saw the first one on the consensus clients page and in the indexer. Change ClientIndex to `*int` so that only explicit configuration (YAML or env) triggers the single-endpoint selection. --- types/config.go | 2 +- utils/config.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/types/config.go b/types/config.go index dba8714a..1c552e36 100644 --- a/types/config.go +++ b/types/config.go @@ -97,7 +97,7 @@ type Config struct { Endpoint string `yaml:"endpoint" envconfig:"BEACONAPI_ENDPOINT"` Endpoints []EndpointConfig `yaml:"endpoints"` EndpointsURL string `yaml:"endpointsUrl" envconfig:"BEACONAPI_ENDPOINTS_URL"` - ClientIndex int `yaml:"clientIndex" envconfig:"BEACONAPI_CLIENT_INDEX"` + ClientIndex *int `yaml:"clientIndex" envconfig:"BEACONAPI_CLIENT_INDEX"` LocalCacheSize int `yaml:"localCacheSize" envconfig:"BEACONAPI_LOCAL_CACHE_SIZE"` SkipFinalAssignments bool `yaml:"skipFinalAssignments" envconfig:"BEACONAPI_SKIP_FINAL_ASSIGNMENTS"` diff --git a/utils/config.go b/utils/config.go index e8396e8c..31e1ddd3 100644 --- a/utils/config.go +++ b/utils/config.go @@ -46,9 +46,9 @@ func ReadConfig(cfg *types.Config, path string) error { } } - // ClientIndex selects a specific endpoint by index (0-based) - if cfg.BeaconApi.ClientIndex >= 0 && cfg.BeaconApi.ClientIndex < len(cfg.BeaconApi.Endpoints) { - selectedEndpoint := cfg.BeaconApi.Endpoints[cfg.BeaconApi.ClientIndex] + // ClientIndex selects a specific endpoint by index (0-based), when explicitly set + if cfg.BeaconApi.ClientIndex != nil && *cfg.BeaconApi.ClientIndex >= 0 && *cfg.BeaconApi.ClientIndex < len(cfg.BeaconApi.Endpoints) { + selectedEndpoint := cfg.BeaconApi.Endpoints[*cfg.BeaconApi.ClientIndex] cfg.BeaconApi.Endpoints = []types.EndpointConfig{selectedEndpoint} }