Skip to content

Fix IPXEBootConfig URLs for digest-based image references#329

Merged
xkonni merged 2 commits into
mainfrom
fix/url-encode-image-query-params
Jun 10, 2026
Merged

Fix IPXEBootConfig URLs for digest-based image references#329
xkonni merged 2 commits into
mainfrom
fix/url-encode-image-query-params

Conversation

@xkonni

@xkonni xkonni commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The old strings.Split(image, ":") code split a digest reference like registry/org/image@sha256:<hash> at the colon, producing imageName=...@sha256&version=<hash> in the stored IPXEBootConfig URL, causing HTTP 400 errors during iPXE boot
  • Switch URL construction to url.Values.Encode() so query parameters are properly percent-encoded
  • Add V(1) log lines for specImage, imageName, imageVersion, and the three built URLs to aid future debugging

Fixes #328

Test plan

  • go test ./internal/controller/ -run TestImageURLFromSpecImage — verifies all three layer URLs have correct imageName, version (with sha256: prefix), and layerDigest parameters for a long-hostname digest reference

Summary by CodeRabbit

  • New Features

    • Enhanced image proxy URL construction with improved parameter handling and logging.
  • Bug Fixes

    • Improved handling of container image references with digest information to ensure proper URL formatting.
  • Tests

    • Added regression test for image URL builder to validate query parameter preservation and formatting.

@xkonni xkonni requested review from atd9876 and hardikdr June 10, 2026 12:33
@xkonni xkonni force-pushed the fix/url-encode-image-query-params branch from 71cfa24 to e558878 Compare June 10, 2026 12:34
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@xkonni, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 49 minutes and 33 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 289d412e-9498-4134-9ece-3b37efb8267f

📥 Commits

Reviewing files that changed from the base of the PR and between 563ee22 and c3b168b.

📒 Files selected for processing (1)
  • server/imageproxyserver.go
📝 Walkthrough

Walkthrough

The PR consolidates image URL generation for iPXE boot configs. A new buildImageURL helper uses url.Values.Encode() to safely percent-encode query parameters containing digest colons, replacing inline fmt.Sprintf formatting. The PXE controller's getImageDetailsFromConfig is refactored to call this helper for kernel, initrd, and squashfs layer URLs, and now logs the parsed image reference and computed URLs.

Changes

Digest URL encoding consolidation

Layer / File(s) Summary
URL encoding helper and validation
internal/controller/serverbootconfig_helpers.go, internal/controller/serverbootconfig_helpers_test.go
The buildImageURL function uses url.Values to percent-encode imageName, version, and layerDigest query parameters, safely handling colons in digest strings. TestImageURLFromSpecImage validates that digest-suffixed image names are properly separated and the sha256: prefix is preserved in the version parameter.
PXE controller URL generation refactoring
internal/controller/serverbootconfiguration_pxe_controller.go
getImageDetailsFromConfig now accepts a logger parameter and constructs kernel, initrd, and squashfs image URLs by calling buildImageURL instead of inline fmt.Sprintf, while emitting logs for parsed image references and computed URLs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

area/metal-automation, ok-to-publish, ok-to-image, size/S

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main fix: correcting IPXEBootConfig URLs for digest-based image references, which aligns with the core changeset.
Description check ✅ Passed The description adequately explains the root cause, the fix using url.Values.Encode(), added logging, and references issue #328 with a test plan.
Linked Issues check ✅ Passed The PR fully addresses issue #328 by switching to url.Values.Encode() for proper percent-encoding of query parameters and adding diagnostic logging.
Out of Scope Changes check ✅ Passed All changes directly support fixing digest-based image reference URLs and adding test coverage; no unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/url-encode-image-query-params

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@xkonni xkonni requested review from adracus and afritzler June 10, 2026 12:51
@xkonni xkonni force-pushed the fix/url-encode-image-query-params branch from e558878 to a2fa098 Compare June 10, 2026 13:08
asergeant01
asergeant01 previously approved these changes Jun 10, 2026
@xkonni xkonni marked this pull request as draft June 10, 2026 14:04
@xkonni xkonni changed the title Fix malformed IPXEBootConfig URLs for digest-based image references Fix IPXEBootConfig URLs for digest-based image references Jun 10, 2026
@xkonni xkonni force-pushed the fix/url-encode-image-query-params branch from a2fa098 to b2fbc19 Compare June 10, 2026 14:39
@xkonni xkonni requested a review from asergeant01 June 10, 2026 14:39
@xkonni xkonni force-pushed the fix/url-encode-image-query-params branch from b2fbc19 to 5fc6326 Compare June 10, 2026 14:40
The old strings.Split(image, ":") code split a digest reference like
registry/org/image@sha256:<hash> at the colon, producing a malformed
imageName=...@sha256&version=<hash> in the stored URL, causing HTTP 400
errors during iPXE boot.

Switch URL construction to use url.Values.Encode() so query parameters
are properly percent-encoded, and add V(1) log lines for specImage,
imageName, imageVersion, and the three built URLs to aid future debugging.

Fixes #328

Signed-off-by: Konstantin Koslowski <konstantin.koslowski@sap.com>
@xkonni xkonni force-pushed the fix/url-encode-image-query-params branch from 5fc6326 to 563ee22 Compare June 10, 2026 14:41
@xkonni xkonni marked this pull request as ready for review June 10, 2026 14:41
asergeant01
asergeant01 previously approved these changes Jun 10, 2026

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
internal/controller/serverbootconfig_helpers.go (1)

68-77: Query parameter keys match the server parser (imageName, layerDigest, version)

buildImageURL sets imageName, version, and layerDigest, and parseImageURL uses imageKey="imageName", versionKey="version", and layerDigestKey="layerDigest" to read them; the helper test also asserts these exact query keys. The only mismatch is the error string ('image'/'layer'/'version') which is misleading—consider aligning it with the actual parameter names.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/controller/serverbootconfig_helpers.go` around lines 68 - 77, The
error messages in parseImageURL use generic labels ('image'/'layer'/'version')
that don't match the actual query parameter keys set by buildImageURL
(imageName, version, layerDigest) and the helper test; update the error strings
in parseImageURL (and any related test expectations) to reference the exact
parameter names imageName, layerDigest, and version so they align with
buildImageURL, the parser keys (imageKey, versionKey, layerDigestKey), and the
helper test assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/controller/serverbootconfig_helpers.go`:
- Around line 68-77: The error messages in parseImageURL use generic labels
('image'/'layer'/'version') that don't match the actual query parameter keys set
by buildImageURL (imageName, version, layerDigest) and the helper test; update
the error strings in parseImageURL (and any related test expectations) to
reference the exact parameter names imageName, layerDigest, and version so they
align with buildImageURL, the parser keys (imageKey, versionKey,
layerDigestKey), and the helper test assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 46d51669-83c0-452e-95d9-a4ac537c134b

📥 Commits

Reviewing files that changed from the base of the PR and between 5d3a022 and 563ee22.

📒 Files selected for processing (3)
  • internal/controller/serverbootconfig_helpers.go
  • internal/controller/serverbootconfig_helpers_test.go
  • internal/controller/serverbootconfiguration_pxe_controller.go

Signed-off-by: Konstantin Koslowski <konstantin.koslowski@sap.com>
@xkonni xkonni merged commit e198b0f into main Jun 10, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Roadmap Jun 10, 2026
@xkonni xkonni deleted the fix/url-encode-image-query-params branch June 10, 2026 14:56
@afritzler afritzler added the bug Something isn't working label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size/M

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Digest-based image references generate malformed IPXEBootConfig URLs

3 participants