Skip to content

fix(pkgfetcher): encode + as %2B in download URLs#477

Merged
srmungar merged 1 commit intomainfrom
fix/url-encode-plus-in-downloads
Mar 11, 2026
Merged

fix(pkgfetcher): encode + as %2B in download URLs#477
srmungar merged 1 commit intomainfrom
fix/url-encode-plus-in-downloads

Conversation

@arodage
Copy link
Copy Markdown
Contributor

@arodage arodage commented Mar 11, 2026

Merge Checklist

All boxes should be checked before merging the PR

  • The changes in the PR have been built and tested
  • Documentation has been updated to reflect the changes (or no doc update needed)
  • Ready to merge

Description

Problem: When downloading .deb packages from S3/CloudFront-backed repositories (e.g. ECI, AMR), packages with + in their filenames fail with HTTP 403 Forbidden. JIRA#ITEP-88403

Examples of affected packages:

  • systemd-boot_255.4-1ubuntu8.12-ecir8+etf+taprio+mqprio+fpe+ffw_amd64.deb
  • systemd-resolved_255.4-1ubuntu8.12-ecir8+etf+taprio+mqprio+fpe+ffw_amd64.deb
  • systemd-timesyncd_255.4-1ubuntu8.12-ecir8+etf+taprio+mqprio+fpe+ffw_amd64.deb

Root cause: S3/CloudFront interprets a literal + in the URL path as a space character (per RFC 1630 query-string encoding). The server cannot find the object and returns 403 (not 404) because the S3 bucket is configured to hide missing objects.

Fix: In downloadWithRetry(), encode + as %2B in the HTTP request URL only. The local filename retains the original +. Single-line change:

requestURL := strings.ReplaceAll(url, "+", "%2B")

Any Newly Introduced Dependencies

None.

How Has This Been Tested?

  1. Built os-image-composer with the fix applied
  2. Ran full image build using ubuntu24-x86_64-robotics-jazzy-raw.yml template which uses ECI and AMR repos containing packages with + in filenames
  3. Verified all 2737 packages downloaded successfully (0 failures) — previously the ECI systemd packages with +etf+taprio+mqprio+fpe+ffw in their names all failed with 403
  4. Verified the downloaded .deb files retain the original + in their local filenames (needed by dpkg-scanpackages)

@arodage arodage requested a review from a team as a code owner March 11, 2026 00:59
Copilot AI review requested due to automatic review settings March 11, 2026 00:59
@arodage arodage changed the title fix(pkgfetcher): encode + as %2B in download URLs for S3/CloudFront repos fix(pkgfetcher): encode + as %2B in download URLs Mar 11, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes package download failures from S3/CloudFront-backed repositories by ensuring + characters in package filenames are encoded as %2B in HTTP request URLs, avoiding 403s caused by + being interpreted as a space.

Changes:

  • Add strings dependency to support URL rewriting.
  • Rewrite the request URL in downloadWithRetry() to replace + with %2B before calling client.Get().

You can also share your feedback on Copilot code review. Take the survey.

Comment thread internal/ospackage/pkgfetcher/pkgfetcher.go Outdated
Comment thread internal/ospackage/pkgfetcher/pkgfetcher.go Outdated
@arodage arodage force-pushed the fix/url-encode-plus-in-downloads branch from c17074c to 16b0cd6 Compare March 11, 2026 05:31
@srmungar srmungar merged commit d617687 into main Mar 11, 2026
34 checks passed
@srmungar srmungar deleted the fix/url-encode-plus-in-downloads branch March 11, 2026 15:24
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.

4 participants