-
Notifications
You must be signed in to change notification settings - Fork 65
Fixing release-5 prefix bug for OCP 5.0 #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-bot
merged 1 commit into
openshift:main
from
bradmwilliams:ocp-5-prefix-fix
Feb 26, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 1850
🏁 Script executed:
rg "TrimPrefixes" --type goRepository: openshift/release-controller
Length of output: 367
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 678
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 1805
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 50384
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 54
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 54
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 54
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 109
🏁 Script executed:
rg "type.*Config\s+struct" cmd/release-controller/ -A 20Repository: openshift/release-controller
Length of output: 54
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 2402
🏁 Script executed:
rg "release\.Config\.To" cmd/release-controller/ -B 5 -A 5Repository: openshift/release-controller
Length of output: 1162
🏁 Script executed:
rg "Config struct" cmd/release-controller/ -A 15Repository: openshift/release-controller
Length of output: 54
🏁 Script executed:
rg "type Release struct" --type go -A 20Repository: openshift/release-controller
Length of output: 6184
🏁 Script executed:
rg "Config\s+struct" --type go cmd/release-controller/ -A 15Repository: openshift/release-controller
Length of output: 54
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 468
🏁 Script executed:
grep -n "^type ReleaseConfig struct" pkg/release-controller/types.go -A 50Repository: openshift/release-controller
Length of output: 2863
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 456
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 552
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 570
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 1344
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 7144
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 2092
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 54
🏁 Script executed:
Repository: openshift/release-controller
Length of output: 413
Add boundary-aware prefix trimming to prevent silent malformation of stream names
The
TrimPrefixesfunction at lines 243-250 performs raw text prefix matching viastrings.CutPrefix, which can accidentally match partial version numbers. For example, ifrelease.Config.Tocontains"release-50"or"release-50.1", the prefix"release-5"will match and produce"0"or"0.1"respectively, creating malformed stream names passed to line 223.The proposed boundary check (allowing only results that are empty or start with
"."or"-") prevents silent generation of invalid stream suffixes.🔧 Proposed fix
func TrimPrefixes(s string, prefixes ...string) string { - for _, prefix := range prefixes { - if after, found := strings.CutPrefix(s, prefix); found { - return after - } - } - return s + for _, prefix := range prefixes { + if after, found := strings.CutPrefix(s, prefix); found { + // Avoid partial token matches like release-50.x matching release-5 + if after == "" || strings.HasPrefix(after, ".") || strings.HasPrefix(after, "-") { + return after + } + } + } + return s }🤖 Prompt for AI Agents