Skip to content

Conversation

@maradini77
Copy link

## Bug Fix

**What does this PR do? Why is it needed?**

Fixes a logic error in Beacon API host validation where empty or whitespace-only endpoints would pass validation and cause the validator service to start with an invalid configuration.

**Problem**

The original code used `strings.Split()` which always returns at least one element (even if empty), making the `len(hosts) == 0` check ineffective. When `BeaconApiEndpoint` was empty or contained only commas/whitespace, the service would proceed to create a REST client with an empty base URL, leading to runtime failures during HTTP requests.

**Solution**

- Filter out empty strings from the split result before validation
- Ensure the service fails fast with a clear error message when no valid hosts are provided
- Prevent invalid REST client initialization

**Changes**

- Added filtering loop to remove empty host entries
- Improved validation to catch empty/malformed endpoint configurations early


u := strings.ReplaceAll(v.conn.GetBeaconApiUrl(), " ", "")
hosts := strings.Split(u, ",")
rawHosts := strings.Split(u, ",")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a unit test and changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants