Skip to content
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

fix(platform/azure): Add current project id as sourceRepositoryId to azure getPrList #32991

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jessebluemr
Copy link

... to avoid that the bot needs read permissions to all PR source repositories

Changes

This PR adds a second searchCriteria to the Azure getPrList call. The added searchCriteria is the sourceRepositoryId with the id of the current project. This has the effect that only pull requests are returned, which have their sources in branches of the current project or in other words no pull requests from forks are returned.

Context

This PR tries to solve the problem that the user account associated with "Renovate-Git-Token" requires read access to any source repository from which pull requests are created.
Without the read access currently the getPrList call fails and an exception like this is reported:

"err": {
             "message": "Cannot read properties of null (reading 'length')",
             "stack": "TypeError: Cannot read properties of null (reading 'length')\n    at Proxy.getPrList (/home/AzDevOps/work/1/s/node_modules/renovate/lib/modules/platform/azure/index.ts:270:25)\n    at processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at finalizeRepo (/home/AzDevOps/work/1/s/node_modules/renovate/lib/workers/repository/finalize/index.ts:25:18)\n    at Object.renovateRepository (/home/AzDevOps/work/1/s/node_modules/renovate/lib/workers/repository/index.ts:113:7)\n    at attributes.repository (/home/AzDevOps/work/1/s/node_modules/renovate/lib/workers/global/index.ts:206:11)\n    at start (/home/AzDevOps/work/1/s/node_modules/renovate/lib/workers/global/index.ts:191:7)\n    at /home/AzDevOps/work/1/s/node_modules/renovate/lib/renovate.ts:19:22"
           },

I'm not sure if the restriction to PRs only from the current repository has unwanted sideeffects.
Maybe the PR can be changed to be a solution strategie if the fetching of all PRs fails?
Is there a requirement for renovate to see all available PRs including forks?

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

…s to avoid that bot needs read permission to all pr source repositories
@rarkins rarkins changed the title Add current project id as sourceRepositoryId to azure getPrList fix(platform/azure): Add current project id as sourceRepositoryId to azure getPrList Dec 9, 2024
@rarkins
Copy link
Collaborator

rarkins commented Dec 9, 2024

This seems reasonable because I don't think Renovate can create PRs from forks on Azure anyway. We would need someone to run this past a real repository and vouch that it works before merging though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants