Repository navigation
fix: encoding issues for forecastle.stakater.com/url annotation - #558
Merged
msafwankarim merged 2 commits intoApr 8, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes handling of forecastle.stakater.com/url annotations so URLs containing fragments (e.g., #...) are parsed/returned correctly instead of being rewritten/encoded unexpectedly.
Changes:
- Switch URL parsing from
url.ParseRequestURItourl.Parsefor the forecastle URL annotation path. - Add/adjust validation to reject URLs missing a scheme.
- Add unit tests covering fragment-containing URLs for Ingress and the shared URL-annotation validator.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/kube/wrappers/map.go | Updates shared URL-annotation parsing/validation logic. |
| pkg/kube/wrappers/ingress.go | Updates Ingress URL override parsing/validation to accept fragments. |
| pkg/kube/wrappers/ingress_test.go | Adds a test case asserting fragment URLs are preserved for Ingress. |
| pkg/kube/wrappers/httproute_test.go | Adds tests asserting fragment URLs are preserved for shared validation helper. |
Comments suppressed due to low confidence (3)
pkg/kube/wrappers/map.go:42
getAndValidateURLAnnotationreturnsparsedURL.String(), which canonicalizes/escapes the URL and may still modify the annotation value (e.g., escaping characters or normalizing case). Since the goal is to preserve the URL exactly as provided in the annotation, consider returning the originalurlValueafter validation instead of re-serializing the parsed URL.
parsedURL, err := url.Parse(urlValue)
if err != nil || parsedURL.Scheme == "" {
logger.Warn(err)
return ""
}
return parsedURL.String()
}
pkg/kube/wrappers/map.go:41
- Validation is currently too permissive: checking only
parsedURL.Scheme != ""will treat values likehttp:example.com(scheme set, host empty / opaque URL) as valid. README docs indicate the value must be anhttp://orhttps://URL, so it would be safer to enforceSchemein {http,https} and require a non-emptyHost(and typicallyOpaque == "") before accepting the annotation.
parsedURL, err := url.Parse(urlValue)
if err != nil || parsedURL.Scheme == "" {
logger.Warn(err)
return ""
}
return parsedURL.String()
pkg/kube/wrappers/ingress.go:71
- This block duplicates URL validation logic that already exists in
getAndValidateURLAnnotationand has the same issues (possible<nil>logging when scheme is missing, and reliance onparsedURL.String()which can re-encode/canonicalize). Consider delegating togetAndValidateURLAnnotationhere so validation/normalization behavior stays consistent across wrappers and fixes only need to be made in one place.
if urlFromAnnotation := iw.GetAnnotationValue(annotations.ForecastleURLAnnotation); urlFromAnnotation != "" {
parsedURL, err := url.Parse(urlFromAnnotation)
if err != nil || parsedURL.Scheme == "" {
logger.Warn(err)
return ""
}
return parsedURL.String()
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
msafwankarim
approved these changes
Apr 8, 2026
msafwankarim
deleted the
SA-8185-encoding-issues-for-forecastle-url-annotation
branch
April 8, 2026 08:29
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#556