feat: requests to remote always include user-agent #21684
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.
I have a grpc Remote Execution API server that I use as a backend remote cache for both pants and bazel. I want to be able to distinguish between requests that came from bazel and those that came from pants. I originally relied on the user agent header but found that it was omitted if I configured any other headers.
In the reference sections for
remote_execution_headers
andremote_store_headers
, the pants docs state that "Pants may add additional headers." I think User-Agent is one header that would be useful if always present.This PR removes User-Agent from
DEFAULT_EXECUTION_OPTIONS
and opts instead to merge it with user-provided headers. That is, the following configuration:would result in the following HTTP Headers:
These changes are intended to allow the user, if needed, to provide a custom user agent by setting it explicitly in
remote_store_headers
orremote_execution_headers
. I'm not deeply familiar with python, so please let me know if there are any changes you'd like me to make. Thank you!