feat(core): Add user-agent header to network requests and create yarn version file#7155
Open
thegoddo wants to merge 1 commit into
Open
feat(core): Add user-agent header to network requests and create yarn version file#7155thegoddo wants to merge 1 commit into
thegoddo wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's the problem this PR addresses?
Currently, outgoing HTTP requests from Yarn do not specify a unique, standardized
User-Agentheader, causing underlying request engines (likegot) to default to their own client string formats.This presents a challenge for enterprise networks, corporate firewalls, and system administrators who monitor incoming telemetry. Without a distinct
User-Agentidentifying the package manager and its environment, administrators cannot accurately track, audit, or whitelist/allowlist traffic originating specifically from Yarn.Closes #7146
How did you fix it?
userAgentheader within the centralrequestImplexecution loop insidepackages/yarnpkg-core/sources/httpUtils.ts.yarn/${yarnVersion} node/${process.version}to dynamically capture both the engine variant and runtime environment. It leverages the monorepo'sYarnVersionmodule, safely falling back to an'unknown'flag if running outside a packaged environment.'user-agent'property at the top of theheadersassignment block insidegotOptions, using the object spread operator (...headers) right below it. This ensures any plugin or specific utility passing an explicit custom header will cleanly overwrite the default.userAgent), while keeping the network protocol configuration key lowercase ('user-agent') as expected by the underlying HTTP utility clients..yarn/versions/directory to explicitly link a patch release across@yarnpkg/core,@yarnpkg/cli, and its dependent monorepo workspaces to prevent pipeline dependency validation conflicts.Checklist
I have read the Contributing Guide.
I have set the packages that need to be released for my changes to be effective.
I will check that all automated PR checks pass before the PR gets reviewed.