Skip to content

Conversation

@ab-ghosh
Copy link
Member

@ab-ghosh ab-ghosh commented Nov 17, 2025

Changes

This PR fixes a bug where multiple Git repositories on the same host could not use different credentials. When users linked multiple secrets to a ServiceAccount for different repositories on the same Git server (e.g., github.com/org/repo1 and github.com/org/repo2), Tekton would incorrectly use the first credential for all repositories, authentication failures. The root cause was that Git's credential helper only matched by hostname, ignoring the repository path. This fix adds useHttpPath = true to Git credential contexts, instructing Git to match credentials based on the full repository URL. The solution is backwards compatible, requires no configuration changes, and includes comprehensive test coverage including a new test specifically for this scenario.

  • pkg/credentials/gitcreds/basic.go: Added useHttpPath=true to configBlurb()
  • pkg/credentials/gitcreds/creds_test.go: Updated tests and added
    TestBasicFlagHandlingMultipleReposSameHost to verify the fix
  • Fixed incorrect error message in test

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

Fixed Git credential matching to support multiple repositories on the same host with different credentials. Previously, when using multiple secrets for different repositories on the same Git server (e.g., github.com/org/repo1 and github.com/org/repo2), it incorrectly use the first credential for all repositories, causing authentication failures. Git credential contexts now include `useHttpPath = true`, enabling proper per-repository credential selection.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Nov 17, 2025
@tekton-robot tekton-robot requested review from abayer and jerop November 17, 2025 19:48
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign vdemeester after the PR has been reviewed.
You can assign the PR to them by writing /assign @vdemeester in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 17, 2025
@tekton-robot
Copy link
Collaborator

@ab-ghosh: The label(s) kind/fix cannot be applied, because the repository doesn't have them.

In response to this:

/kind fix

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ab-ghosh
Copy link
Member Author

/kind bug

@tekton-robot tekton-robot added the kind/bug Categorizes issue or PR as related to a bug. label Nov 18, 2025
@ab-ghosh ab-ghosh force-pushed the fix-multiple-git-credentials-same-host branch from f7381cf to d1e3d33 Compare November 19, 2025 06:03
@ab-ghosh ab-ghosh force-pushed the fix-multiple-git-credentials-same-host branch from d1e3d33 to b5254f2 Compare November 20, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants