Skip to content

fix: URL-escape placeholder values in BuildLookasideURL and dist-git URL construction#74

Open
Copilot wants to merge 7 commits intomainfrom
copilot/fix-build-lookaside-url-substitution
Open

fix: URL-escape placeholder values in BuildLookasideURL and dist-git URL construction#74
Copilot wants to merge 7 commits intomainfrom
copilot/fix-build-lookaside-url-substitution

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

BuildLookasideURL and dist-git URL construction perform raw string substitution for $pkg, $filename, $hashtype, and $hash without URL-encoding. Reserved characters (/, ?, #, %) in substituted values alter URL structure silently.

Changes

  • fedorasource.go: Apply url.PathEscape() to all placeholder values before substitution in BuildLookasideURL; validate the final URL via a shared validateAbsoluteURL helper that calls url.Parse() and verifies a non-empty scheme and host
  • fedorasource.go: Add BuildDistGitURL with the same escaping and validation for $pkg substitution
  • fedorasource.go: Extract validateAbsoluteURL helper to deduplicate URL validation logic shared by both BuildLookasideURL and BuildDistGitURL
  • fedorasource.go: Normalize hashType to lowercase once at the start of BuildLookasideURL to avoid redundant strings.ToLower() calls and ensure the placeholder guard validates the actual substituted form
  • fedorasource.go: Validate constructed URLs are absolute with a non-empty scheme and host, rejecting misconfigured templates that url.Parse alone would silently accept (e.g. example.com/$pkg)
  • fedorasource.go: Use %#q for placeholder values in error messages for consistency with other format verbs
  • fedorasource.go: Fix doc comment placement so validateAbsoluteURL and BuildLookasideURL each have properly separated, correctly attached doc comments
  • fedorasourceprovider.go: Replace two raw strings.ReplaceAll dist-git URL constructions with BuildDistGitURL
  • fedorasource_test.go: Add test coverage for /, ?, #, %zz in both filename and packageName for both builders, plus tests for the uppercase hashType placeholder bypass and missing-scheme template rejection

Example

// Before: raw substitution — "foo/bar" creates extra path segments
uri = strings.ReplaceAll(uri, PlaceholderPkg, packageName)

// After: path-escaped — "foo/bar" becomes "foo%2Fbar"
uri = strings.ReplaceAll(uri, PlaceholderPkg, url.PathEscape(packageName))

…DistGitURL

Apply url.PathEscape() to all placeholder values before substitution in
BuildLookasideURL so reserved URL characters (/, ?, #, %) don't alter
URL structure. Parse and validate the final URL before returning.

Create BuildDistGitURL for dist-git URL construction with the same
path-escaping and validation protections. Update the two raw
strings.ReplaceAll call sites in fedorasourceprovider.go to use the
new function.

Add comprehensive test coverage for both functions with reserved URL
characters in filename and packageName inputs.

Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/c56e9983-31d5-4a6d-9ac6-e6fee388466f

Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 7, 2026 17:08
Copilot AI changed the title [WIP] Fix URL encoding in BuildLookasideURL for valid substitutions fix: URL-escape placeholder values in BuildLookasideURL and dist-git URL construction Apr 7, 2026
Copilot AI requested a review from dmcilvaney April 7, 2026 17:10
@dmcilvaney dmcilvaney marked this pull request as ready for review April 7, 2026 18:06
Copilot AI review requested due to automatic review settings April 7, 2026 18:06
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

Note

Copilot was unable to run its full agentic suite in this review.

This PR hardens Fedora lookaside and dist-git URL generation by URL-escaping substituted placeholder values and validating the resulting URLs to prevent reserved characters from silently altering URL structure.

Changes:

  • Path-escape placeholder substitutions in BuildLookasideURL and validate the resulting URL.
  • Introduce BuildDistGitURL (escaped + validated) and use it in the Fedora source provider.
  • Add tests covering reserved characters in filenames and package names for both URL builders.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
internal/providers/sourceproviders/fedorasource/fedorasource.go Escapes placeholder substitutions, adds URL validation, and introduces BuildDistGitURL.
internal/providers/sourceproviders/fedorasourceprovider.go Switches dist-git URL construction to BuildDistGitURL and propagates errors.
internal/providers/sourceproviders/fedorasource/fedorasource_test.go Adds regression tests for reserved characters and malformed percent sequences.

@dmcilvaney
Copy link
Copy Markdown
Contributor

@copilot Can you have a look at the review comments? Two seem worth investigating. Please double check the error formatting one, and imo the template count isn't an issue (but open to pushback).

…ideURL

The placeholder-in-value guard checked raw hashType but substitution
uses strings.ToLower(hashType). This meant hashType="$PKG" bypassed
the guard and was substituted as "$pkg" (matching PlaceholderPkg).

Check the normalized (lowercased) hashType against placeholders to
close this bypass. Add test case for the scenario.

Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/ac27db32-1692-4bde-bb94-c7c0b4f0fa5d

Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 7, 2026

@copilot Can you have a look at the review comments? Two seem worth investigating. Please double check the error formatting one, and imo the template count isn't an issue (but open to pushback).

Investigated both items:

  1. hashType case-sensitivity bug — Real issue. The placeholder guard checked raw hashType but substitution lowercases it, so hashType="$PKG" bypassed the guard and was substituted as "$pkg". Fixed in 9192372 by checking strings.ToLower(hashType) against placeholders, with a new test case.

  2. Error formatting — Confirmed the \n%w pattern is consistent with every other error in fedorasourceprovider.go (15+ instances). No change needed.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dario.cat
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet -c=4 v-tools/azure-li/tmp/go-build398095445/b575/vet.cfg -importcfg ux-amd64/pkg/tool/linux_amd64/vet diff�� k/azure-linux-dev-tools/azure-linux-dev-tools/inGOINSECURE /home/REDACTED/go/pkg/mod/github.com/goccy/go-yamlGOMOD ux-amd64/pkg/tool/linux_amd64/vet ngci-lint/v2@v2./home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/too-trimpath om/golangci/gola/tmp/go-build398095445/b707/vet.cfg ux-amd64/pkg/tool/linux_amd64/compile ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • example.com
    • Triggering command: /tmp/go-build3323006616/b001/sourceproviders.test /tmp/go-build3323006616/b001/sourceproviders.test -test.testlogfile=/tmp/go-build3323006616/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true g_.a DD8Ln2EKo pkg/mod/golang.o--64 user.name (dns block)
  • go.opentelemetry.io
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet -c=4 v-tools/azure-li/tmp/go-build398095445/b575/vet.cfg -importcfg ux-amd64/pkg/tool/linux_amd64/vet diff�� k/azure-linux-dev-tools/azure-linux-dev-tools/inGOINSECURE /home/REDACTED/go/pkg/mod/github.com/goccy/go-yamlGOMOD ux-amd64/pkg/tool/linux_amd64/vet ngci-lint/v2@v2./home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/too-trimpath om/golangci/gola/tmp/go-build398095445/b707/vet.cfg ux-amd64/pkg/tool/linux_amd64/compile ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • go.szostok.io
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet -c=4 v-tools/azure-li/tmp/go-build398095445/b575/vet.cfg -importcfg ux-amd64/pkg/tool/linux_amd64/vet diff�� k/azure-linux-dev-tools/azure-linux-dev-tools/inGOINSECURE /home/REDACTED/go/pkg/mod/github.com/goccy/go-yamlGOMOD ux-amd64/pkg/tool/linux_amd64/vet ngci-lint/v2@v2./home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/too-trimpath om/golangci/gola/tmp/go-build398095445/b707/vet.cfg ux-amd64/pkg/tool/linux_amd64/compile ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • go.uber.org
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet -c=4 v-tools/azure-li/tmp/go-build398095445/b575/vet.cfg -importcfg ux-amd64/pkg/tool/linux_amd64/vet diff�� k/azure-linux-dev-tools/azure-linux-dev-tools/inGOINSECURE /home/REDACTED/go/pkg/mod/github.com/goccy/go-yamlGOMOD ux-amd64/pkg/tool/linux_amd64/vet ngci-lint/v2@v2./home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/too-trimpath om/golangci/gola/tmp/go-build398095445/b707/vet.cfg ux-amd64/pkg/tool/linux_amd64/compile ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • go.yaml.in
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet -c=4 v-tools/azure-li/tmp/go-build398095445/b575/vet.cfg -importcfg ux-amd64/pkg/tool/linux_amd64/vet diff�� k/azure-linux-dev-tools/azure-linux-dev-tools/inGOINSECURE /home/REDACTED/go/pkg/mod/github.com/goccy/go-yamlGOMOD ux-amd64/pkg/tool/linux_amd64/vet ngci-lint/v2@v2./home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/too-trimpath om/golangci/gola/tmp/go-build398095445/b707/vet.cfg ux-amd64/pkg/tool/linux_amd64/compile ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • gopkg.in
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet -c=4 v-tools/azure-li/tmp/go-build398095445/b575/vet.cfg -importcfg ux-amd64/pkg/tool/linux_amd64/vet diff�� k/azure-linux-dev-tools/azure-linux-dev-tools/inGOINSECURE /home/REDACTED/go/pkg/mod/github.com/goccy/go-yamlGOMOD ux-amd64/pkg/tool/linux_amd64/vet ngci-lint/v2@v2./home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/too-trimpath om/golangci/gola/tmp/go-build398095445/b707/vet.cfg ux-amd64/pkg/tool/linux_amd64/compile ux-amd64/pkg/tool/linux_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

internal/providers/sourceproviders/fedorasource/fedorasource.go:333

  • When the placeholder check fails for hashType, the error reports the normalized (lowercased) value rather than the caller-provided value (e.g., $PKG will be reported as $pkg). To keep error messages actionable, consider checking with the normalized value but reporting the original input in the error (or include both original and normalized forms).
	// Check the normalized (lowercased) hashType since that is the form actually substituted.
	for _, v := range []string{packageName, fileName, strings.ToLower(hashType), hash} {
		for _, p := range allPlaceholders {
			if strings.Contains(v, p) {
				return "", fmt.Errorf("value %#q contains placeholder %s, which would cause ambiguous substitution", v, p)
			}

Replace the validateAbsoluteURL helper with inline validation per
reviewer suggestion: url.Parse() for syntax, then check u.Scheme and
u.Host are non-empty. This catches misconfigured templates (e.g.
missing scheme) that url.Parse alone would silently accept.

Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/661f751e-7043-4004-9580-01a1ea6036f3

Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 7, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dario.cat
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet ternal/app/azlde/home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/tool/linux_amd64/vet mpile rg/toolchain@v0.GOMODCACHE ux-amd64/pkg/tool/linux_amd64/vet log -1 %cd ux-amd64/pkg/tool/linux_amd64/vet -- k/azure-linux-de/tmp/go-build2184995870/b724/vet.cfg 0.1-go1.25.6.linux-amd64/bin/go ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • example.com
    • Triggering command: /tmp/go-build1523033447/b001/sourceproviders.test /tmp/go-build1523033447/b001/sourceproviders.test -test.testlogfile=/tmp/go-build1523033447/b001/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true get 83FPnLSVe pkg/mod/golang.o--64 committer.name (dns block)
  • go.opentelemetry.io
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet ternal/app/azlde/home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/tool/linux_amd64/vet mpile rg/toolchain@v0.GOMODCACHE ux-amd64/pkg/tool/linux_amd64/vet log -1 %cd ux-amd64/pkg/tool/linux_amd64/vet -- k/azure-linux-de/tmp/go-build2184995870/b724/vet.cfg 0.1-go1.25.6.linux-amd64/bin/go ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • go.szostok.io
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet ternal/app/azlde/home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/tool/linux_amd64/vet mpile rg/toolchain@v0.GOMODCACHE ux-amd64/pkg/tool/linux_amd64/vet log -1 %cd ux-amd64/pkg/tool/linux_amd64/vet -- k/azure-linux-de/tmp/go-build2184995870/b724/vet.cfg 0.1-go1.25.6.linux-amd64/bin/go ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • go.uber.org
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet ternal/app/azlde/home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/tool/linux_amd64/vet mpile rg/toolchain@v0.GOMODCACHE ux-amd64/pkg/tool/linux_amd64/vet log -1 %cd ux-amd64/pkg/tool/linux_amd64/vet -- k/azure-linux-de/tmp/go-build2184995870/b724/vet.cfg 0.1-go1.25.6.linux-amd64/bin/go ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • go.yaml.in
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet ternal/app/azlde/home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/tool/linux_amd64/vet mpile rg/toolchain@v0.GOMODCACHE ux-amd64/pkg/tool/linux_amd64/vet log -1 %cd ux-amd64/pkg/tool/linux_amd64/vet -- k/azure-linux-de/tmp/go-build2184995870/b724/vet.cfg 0.1-go1.25.6.linux-amd64/bin/go ux-amd64/pkg/tool/linux_amd64/vet (dns block)
  • gopkg.in
    • Triggering command: /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses /home/REDACTED/.cache/go-build/7b/7be0cdfd4e5e66df21672375347bd23e46040e0c601b55d1ed8bef64f03acd06-d/go-licenses report --ignore golang.org/x --ignore github.com/microsoft/azure-linux-dev-tools ./... ux-amd64/pkg/tool/linux_amd64/vet ternal/app/azlde/home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.6.linux-amd64/pkg/tool/linux_amd64/vet mpile rg/toolchain@v0.GOMODCACHE ux-amd64/pkg/tool/linux_amd64/vet log -1 %cd ux-amd64/pkg/tool/linux_amd64/vet -- k/azure-linux-de/tmp/go-build2184995870/b724/vet.cfg 0.1-go1.25.6.linux-amd64/bin/go ux-amd64/pkg/tool/linux_amd64/vet (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


for _, v := range []string{packageName, fileName, hashType, hash} {
// Check the normalized (lowercased) hashType since that is the form actually substituted.
for _, v := range []string{packageName, fileName, strings.ToLower(hashType), hash} {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit-pick: we're doing strings.ToLower(hashType) twice inside BuildLookasideURL. What do you think about doing hashType = strings.ToLower(hashType) at the beginning of the function to avoid repetition?

// resulting URL is not valid.
func BuildDistGitURL(template, packageName string) (string, error) {
if strings.Contains(packageName, PlaceholderPkg) {
return "", fmt.Errorf("package name %#q contains placeholder %s, which would cause ambiguous substitution",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
return "", fmt.Errorf("package name %#q contains placeholder %s, which would cause ambiguous substitution",
return "", fmt.Errorf("package name %#q contains placeholder %#q, which would cause ambiguous substitution",

Copy link
Copy Markdown
Contributor

@PawelWMS PawelWMS left a comment

Choose a reason for hiding this comment

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

Left small nit-pick comments but looks good even if they are ignored.

@dmcilvaney
Copy link
Copy Markdown
Contributor

@copilot please look at PawelWMS's comments.

Address PawelWMS's review nit-picks:
- Normalize hashType with strings.ToLower() once at the top of
  BuildLookasideURL instead of calling it twice
- Use %#q instead of %s for placeholder values in error messages
  for consistency with other format verbs in the same messages

Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/577c691c-31b1-42bc-8827-4f7cdad70ddd

Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 7, 2026 23:33
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 7, 2026

@copilot please look at PawelWMS's comments.

Both nit-picks addressed in 8eb81c1:

  1. hashType is now normalized with strings.ToLower() once at the top of BuildLookasideURL instead of twice.
  2. Placeholder values in error messages now use %#q instead of %s in both BuildLookasideURL and BuildDistGitURL.

Copilot AI requested a review from dmcilvaney April 7, 2026 23:34
@dmcilvaney
Copy link
Copy Markdown
Contributor

@copilot would it be worth just making a validator function here?

Extract the duplicated url.Parse + scheme/host validation into a
shared validateAbsoluteURL helper used by both BuildLookasideURL
and BuildDistGitURL.

Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/a9b06a03-7631-4307-a461-8a366892b221

Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 8, 2026 15:50
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot would it be worth just making a validator function here?

Extracted validateAbsoluteURL(uri, label) in e6344c6. Both BuildLookasideURL and BuildDistGitURL now call it instead of duplicating the url.Parse + scheme/host check.

@dmcilvaney
Copy link
Copy Markdown
Contributor

@copilot validateAbsoluteURL and BuildLookasideURL comments seem to have merged a bit, is that intentional formatting? The linter does seem ok with it, but it reads oddly to me. If it is not intentional, can you fix it please?

Move the BuildLookasideURL doc comment to directly precede its function
declaration, so it is no longer merged with the validateAbsoluteURL
comment block.

Agent-Logs-Url: https://github.com/microsoft/azure-linux-dev-tools/sessions/30580b36-4aef-450d-ad65-a38597d233ec

Co-authored-by: dmcilvaney <23200982+dmcilvaney@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 8, 2026 20:25
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 8, 2026

@copilot validateAbsoluteURL and BuildLookasideURL comments seem to have merged a bit, is that intentional formatting? The linter does seem ok with it, but it reads oddly to me. If it is not intention...

Not intentional — when I extracted validateAbsoluteURL, its doc comment was inserted right after the BuildLookasideURL doc comment (which then became detached from its function). Fixed in a5bda4c: each function now has its own properly positioned doc comment.

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.

[Copilot] BuildLookasideURL performs raw placeholder substitution and can generate incorrect or invalid URLs

4 participants