Skip to content

feat: add meaningful User-Agent header to outgoing HTTP requests#7153

Closed
thegoddo wants to merge 1 commit into
yarnpkg:masterfrom
thegoddo:fix/yarn_user_agent
Closed

feat: add meaningful User-Agent header to outgoing HTTP requests#7153
thegoddo wants to merge 1 commit into
yarnpkg:masterfrom
thegoddo:fix/yarn_user_agent

Conversation

@thegoddo

Copy link
Copy Markdown

What's the problem this PR addresses?

Currently, Yarn 4 identifies itself with the default got user-agent string (got (https://github.com/sindresorhus/got)) instead of identifying itself as Yarn. This makes it impossible for sysadmins and DevOps engineers to distinguish Yarn traffic or enforce package manager allow-lists across an organization.

Closes #7149

How did you fix it?

Modified packages/yarnpkg-core/sources/httpUtils.ts inside the requestImpl function.

  • Imported YarnVersion from the core constants.
  • Formulated a meaningful User-Agent string following the standard convention: yarn/${yarnVersion} node/${process.version}.
  • Injected it into gotOptions.headers while utilizing the spread operator (...headers) to ensure any explicitly passed custom headers are preserved and not overwritten.

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.

@thegoddo thegoddo closed this May 27, 2026
@thegoddo thegoddo deleted the fix/yarn_user_agent branch May 27, 2026 10:29
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.

1 participant