fix: Handle non-http(s) URLs in assembleTaskFQDNs#2486
Conversation
Summary of ChangesHello @chmouel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the URL resolution logic by introducing a safeguard that ensures relative task URLs are only processed against HTTP(S) base URLs. This prevents misinterpretation of non-web-based schemes, such as custom catalog references, thereby improving the reliability and correctness of how task URLs are assembled within the system. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly addresses an issue where non-http(s) URLs were not handled properly when resolving relative task URLs. The added check in assembleTaskFQDNs prevents incorrect resolution for custom catalog references. The new unit tests in TestAssembleTaskFQDNs are comprehensive and cover various URL schemes and cases. I have one suggestion to refactor the implementation to be more robust and idiomatic by leveraging url.Parse to check the URL scheme, which also simplifies the code by removing an unnecessary import. Additionally, consider defining constants for the URL schemes to improve maintainability.
There was a problem hiding this comment.
Pull request overview
This PR updates remote task URL resolution so that assembleTaskFQDNs only uses HTTP(S) pipeline references as the base for resolving relative task references, preventing mis-resolution when the pipeline reference uses a non-standard scheme (e.g., custom hub catalogs).
Changes:
- Add an early guard in
assembleTaskFQDNsto skip relative task URL assembly unless the pipeline reference is HTTP(S). - Add unit tests covering HTTP(S), mixed-case schemes, empty pipeline URL, and non-HTTP(S) schemes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pkg/resolve/remote.go |
Adds HTTP(S)-only gate before attempting to parse/join task URLs. |
pkg/resolve/remote_test.go |
Adds table-driven tests for assembleTaskFQDNs covering non-HTTP(S) and mixed-case HTTP(S) inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Added a check to ensure that only http(s) URLs are used as a base for resolving relative task URLs. This prevents incorrect resolution when dealing with custom catalog references or other non-standard URL schemes. Jira: https://issues.redhat.com/browse/SRVKP-10880 Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
a9e0fb8 to
56355f3
Compare
📝 Description of the Change
Added validation to the
assembleTaskFQDNsfunction to ensure that only HTTP(S) URLs are used as a base for resolving relative task URLs. Previously, the function would attempt to resolve relative paths against any URL scheme, including custom catalog references (e.g.,foo://python-build-test-tag-bar:1.2), which led to incorrect URL resolution.The fix adds a case-insensitive check that returns tasks unchanged when the pipeline URL uses a non-HTTP(S) scheme, since relative path resolution is only meaningful for HTTP(S) URLs.
Changes:
pkg/resolve/remote.go(assembleTaskFQDNs:36-41)👨🏻 Linked Jira
https://issues.redhat.com/browse/SRVKP-10880
🔗 Linked GitHub Issue
N/A
🚀 Type of Change
fix:)feat:)feat!:,fix!:)docs:)chore:)refactor:)enhance:)deps:)🧪 Testing Strategy
🤖 AI Assistance
Which LLM was used?
Extent of AI Assistance:
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.