You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(downloads): Add Custom User Agent for download origin - #450
OW2 returned an HTML challenge with HTTP 200 instead of the pinned objectweb-asm archive, causing prepare-sources to fail checksum validation.
Add an optional origin.user-agent to TOML download origins. It applies only to the configured origin, not to lookaside requests. When omitted, downloads retain Go's default User-Agent. There is no built-in curl identity or subprocess, and checksum validation is unchanged.
mage build unit and mage check default passed. Regression tests cover TOML validation and ensure the configured header reaches the origin but not lookaside.
In a temporary checkout of microsoft/AzureLinux at objectweb-asm-9.11.1-cves, added the documented User-Agent to the archive entry and ran azldev component prepare-sources -p objectweb-asm --without-git --network-retries 1. The OW2 origin download succeeded and matched the pinned SHA-512.
Adds an optional per-source origin.user-agent setting so downloads can work with origins that reject Go’s default User-Agent. Lookaside requests, default download behavior, and checksum validation remain unchanged.
Changes:
Adds the configuration field, validation, and schema support without affecting component fingerprints.
Passes the configured User-Agent through download options only for origin requests.
Updates mocks, regression tests, and configuration documentation.
File
Description
schemas/azldev.schema.json
Exposes the optional user-agent setting.
internal/utils/downloader/downloader.go
Adds download options and conditional User-Agent headers.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Changing only origin.user-agent incorrectly reports a build-input change because normalization retains UserAgent; it needs to be cleared and covered by the excluded-fields regression test.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Exclude origin user-agent from component change comparisons
internal/projectconfig/component.go:75
Adding or changing only origin.user-agent makes component changed --without-lockfile report a build-input change even when the pinned source hash is unchanged. The fingerprint:"-" tag does not affect this path: normalizeComponentForComparison clears Origin.Type and Origin.Uri, but retains UserAgent in the JSON comparison. Clear Origin.UserAgent in internal/app/azldev/cmds/component/changed_upstreamcommit.go:327–331 too, and extend TestClassifyHistoricalComponent_ExcludedFieldsUnchanged to cover it.
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
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.
OW2 returned an HTML challenge with HTTP 200 instead of the pinned
objectweb-asmarchive, causingprepare-sourcesto fail checksum validation.Add an optional
origin.user-agentto TOML download origins. It applies only to the configured origin, not to lookaside requests. When omitted, downloads retain Go's default User-Agent. There is no built-in curl identity or subprocess, and checksum validation is unchanged.Related to microsoft/azurelinux#20268
Validation
mage build unitandmage check defaultpassed. Regression tests cover TOML validation and ensure the configured header reaches the origin but not lookaside.microsoft/AzureLinuxatobjectweb-asm-9.11.1-cves, added the documented User-Agent to the archive entry and ranazldev component prepare-sources -p objectweb-asm --without-git --network-retries 1. The OW2 origin download succeeded and matched the pinned SHA-512.