Skip to content

fix: set the correct custom hub catalog type#2371

Merged
chmouel merged 1 commit intotektoncd:mainfrom
pratap0007:fix-customhub-catalog-type
Feb 12, 2026
Merged

fix: set the correct custom hub catalog type#2371
chmouel merged 1 commit intotektoncd:mainfrom
pratap0007:fix-customhub-catalog-type

Conversation

@pratap0007
Copy link
Copy Markdown
Contributor

@pratap0007 pratap0007 commented Jan 5, 2026

📝 Description of the Change

Earlier, the custom hub catalog type was always set to artfacthub.
With this fix, the custom hub catalog URL is validated and correct custom hub
catalog type is set accordingly.

👨🏻‍ Linked Jira

🔗 Linked GitHub Issue

Fixes #

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @pratap0007, 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 handling of custom hub catalogs by introducing automatic type detection. Previously, custom catalogs without a specified type would default to ArtifactHubType. Now, if a URL is provided, the system will attempt to infer the correct hub type via an API call, making the configuration of custom catalogs more robust and user-friendly by reducing the need for manual type specification.

Highlights

  • Automatic Hub Type Detection: Implemented logic to automatically detect the hub type for custom catalogs. If a custom catalog's type is not explicitly specified but a URL is provided, the system will now attempt to determine the hub type via an API call.
  • Enhanced Test Coverage: Added a new test case to validate the automatic hub type detection functionality, ensuring that custom catalogs without an explicit type are correctly identified when a URL is present.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pipelines-as-code
Copy link
Copy Markdown

pipelines-as-code bot commented Jan 5, 2026

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 15f042c fix: set the correct custom hub catalog type

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

@pipelines-as-code pipelines-as-code bot added enhancement New feature or request fix plumbing labels Jan 5, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a useful feature to auto-detect the hub type for custom catalogs when it's not specified. The implementation looks good, and the tests cover the new logic. I have a couple of suggestions to improve code clarity and test robustness.

First, in pkg/params/settings/default.go, there's an opportunity to simplify the logic for auto-detection by removing some redundant code.

Second, in pkg/params/settings/default_test.go, the new test case could be made more robust and comprehensive by using httptest to cover both success and failure scenarios for the API-based detection, avoiding reliance on external network conditions.

Overall, great work on this enhancement!

@pratap0007 pratap0007 force-pushed the fix-customhub-catalog-type branch 2 times, most recently from 862aa60 to bdaa5c0 Compare January 15, 2026 11:12
@zakisk
Copy link
Copy Markdown
Member

zakisk commented Jan 16, 2026

@pratap0007 you should fix go-testing failing test.

@pratap0007 pratap0007 force-pushed the fix-customhub-catalog-type branch from bdaa5c0 to 0febbe2 Compare January 17, 2026 15:42
@zakisk zakisk force-pushed the fix-customhub-catalog-type branch 4 times, most recently from 5e01e1b to b49aef8 Compare January 20, 2026 10:09
@zakisk
Copy link
Copy Markdown
Member

zakisk commented Jan 20, 2026

/retest go-testing

@zakisk
Copy link
Copy Markdown
Member

zakisk commented Jan 20, 2026

/test go-testing

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Jan 23, 2026

@pratap0007 i am confused about what this commits those 😓 can you explain it a bit for me pleaase?

@pratap0007
Copy link
Copy Markdown
Contributor Author

@pratap0007 i am confused about what this commits those 😓 can you explain it a bit for me pleaase?

Hi @chmouel, Currently, we always set the catalog type to artifacthub for custom hub catalog. This commit simply checks the hub catalog URL and assigns the custom hub catalog type, following the same behavior we already done to set the default catalog type in this PR

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Jan 27, 2026

@pratap0007 sounds good, please amend your commit with better details and update the pr description

@pratap0007 pratap0007 force-pushed the fix-customhub-catalog-type branch from e90afcb to 3bee27c Compare January 27, 2026 13:29
@chmouel
Copy link
Copy Markdown
Member

chmouel commented Jan 27, 2026

please read the pr lint feedback as well
image

we need this for categorization

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Jan 27, 2026

it may be useful for you to use cursor/gemini to help producing quality commit and pull request description

@pratap0007 pratap0007 changed the title Auto-detect hub type for custom hub catalogs fix: set the correct custom hub catalog type Jan 27, 2026
@pratap0007 pratap0007 force-pushed the fix-customhub-catalog-type branch from 3bee27c to 8c02956 Compare January 27, 2026 18:32
@pratap0007
Copy link
Copy Markdown
Contributor Author

@chmouel thank you for review, I have updated the PR and could you please take another look?

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Jan 28, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly sets the custom hub catalog type by validating the catalog URL via an API call. The changes are logical and well-tested. I've provided a suggestion for improving performance when detecting types for multiple custom catalogs, and another to enhance debuggability by adding logging to the type detection logic, also noting the use of magic numbers and strings.

catalogType := config[fmt.Sprintf("%s-type", cPrefix)]
if catalogType == "" {
catalogType = hubtypes.ArtifactHubType // default to artifact hub if not specified
catalogType = getHubCatalogTypeViaAPI(config[fmt.Sprintf("%s-url", cPrefix)], httpClient)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

This change introduces a network call inside a loop to determine the catalog type. While this works, it could lead to performance issues if there are multiple custom catalogs configured without an explicit type. The calls to getHubCatalogTypeViaAPI are sequential, and each has a 5-second timeout. With N catalogs, this could delay processing by up to N * 5 seconds.

Consider refactoring to perform these network calls in parallel. You could gather all catalogs that need type detection, launch a goroutine for each detection, and wait for them to complete before storing the results. This would significantly improve performance for configurations with many custom catalogs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's hope people don't have more than one

catalogType := config[fmt.Sprintf("%s-type", cPrefix)]
if catalogType == "" {
catalogType = hubtypes.ArtifactHubType // default to artifact hub if not specified
catalogType = getHubCatalogTypeViaAPI(config[fmt.Sprintf("%s-url", cPrefix)], httpClient)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's hope people don't have more than one


func getHubCatalogTypeViaAPI(hubURL string) string {
func getHubCatalogTypeViaAPI(hubURL string, httpClient *http.Client) string {
if httpClient == nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just pass http.DefaultClient from the caller on line 17 instead of having this condition here?

but then now that i think about you should use r.Clients.HTTP it has many things for security and timeout handling, which mean you need to refactor it to pass it from the initial call to SyncConfig

@pratap0007 pratap0007 force-pushed the fix-customhub-catalog-type branch from 8c02956 to 7188aa7 Compare January 29, 2026 16:45
@zakisk
Copy link
Copy Markdown
Member

zakisk commented Jan 30, 2026

/retest

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Feb 12, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a Server-Side Request Forgery (SSRF) vulnerability due to inadequate validation of the hub URL when automatically detecting the hub catalog type via an API call. Additionally, there's a suggestion to improve the readability and simplify the logic for determining the default hub type.

}

resp, err := http.DefaultClient.Do(req)
resp, err := httpClient.Do(req)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

security-medium medium

The function getHubCatalogTypeViaAPI makes an HTTP GET request to a URL constructed from user-controlled configuration (hub-url or custom catalog URLs) without sufficient validation. An attacker who can modify the Pipelines as Code ConfigMap can specify arbitrary internal URLs, leading to a Server-Side Request Forgery (SSRF) vulnerability. This can be used to probe the internal network from the PAC controller or a user's machine running the tknpac CLI.

To remediate this, implement a strict allow-list for hub URLs or validate that the provided URLs do not point to internal, private, or reserved IP addresses. Additionally, ensure that the URL scheme is restricted to http or https.

@chmouel chmouel force-pushed the fix-customhub-catalog-type branch from 433ad50 to 44b4dde Compare February 12, 2026 09:38
@chmouel
Copy link
Copy Markdown
Member

chmouel commented Feb 12, 2026

i have pushed to this PR a fix for the loop, ptal

@chmouel
Copy link
Copy Markdown
Member

chmouel commented Feb 12, 2026

please use proper conventional commit in your commit message as well.. we need this to generate release note categorization

Earlier, the custom hub catalog type was always
set to artifacthub. With this fix, the custom hub
catalog URL is validated and correct custom hub
catalog type is set accordingly.

Signed-off-by: Shiv Verma <shverma@redhat.com>
@pratap0007 pratap0007 force-pushed the fix-customhub-catalog-type branch from 44b4dde to 15f042c Compare February 12, 2026 10:10
@pratap0007
Copy link
Copy Markdown
Contributor Author

i have pushed to this PR a fix for the loop, ptal

Thank you, @chmouel!

@chmouel chmouel merged commit c3e12c3 into tektoncd:main Feb 12, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request fix plumbing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants