fix: handle encoded commas in URL query parameters #6133
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The Teku validator client is unable to fetch validator statuses from a Lodestar beacon node if more than 1 validator status is requested due to the way they request the data. Lodestar should be able to serve Teku's requests.
Description
The issue is caused by the differing ways the validator clients encode the query parameter values.
Lodestar VC request:
GET /eth/v1/beacon/states/head/validators?id=0x978e96b6b6b474f3f91b705a311906b14a5e2893d15e01f5a0ff210393ace5e0abc8488e844dab00f430364ba4c19b1a&id=0x99f013b0314981b0083e494bdd2989304f9fc9dfd2b0c23b40429d817b02acc78f0b4328e45e745a5c6cc48e8f0e9930 HTTP/1.1
Teku VC request:
GET /eth/v1/beacon/states/head/validators?id=0x978e96b6b6b474f3f91b705a311906b14a5e2893d15e01f5a0ff210393ace5e0abc8488e844dab00f430364ba4c19b1a%2C0x99f013b0314981b0083e494bdd2989304f9fc9dfd2b0c23b40429d817b02acc78f0b4328e45e745a5c6cc48e8f0e9930 HTTP/1.1
-> the comma is URI-encoded as
%2C
. Lodestar then returns an empty array of validator statuses, resulting in Teku VC error messages (and the Teku VC therefore not starting validator duties for the affected validators):I did not test other VC clients but it is possible others do the same.
The Beacon API Swagger seems to result in the comma unencoded in the request.
After reading some discussions on this topic, I am still unsure about which way should be considered technically correct and therefore decided to try supporting both ways on the Lodestar side.
This PR implements support for URI-encoded query parameter values, like the ones Teku VC sends. It is backwards compatible - it supports the comma encoded but also unencoded.