Let a project name the bots whose dependency updates it trusts

What does this MR do and why?

Lets a project name the accounts whose dependency updates it trusts, in a new optional project key in config/mr_approval_flow.yml, dependency_bot_authors.

The first project to need it is gitlab-org/software-delivery/release-platform-canary, whose entry, !4541 (merged), is stacked on this MR. Renovate runs there as the project's own access-token bot (project_79940646_bot_…, user 35035799), not as @gitlab-dependency-update-bot (8420142). bot_dependency matches the author against 8420142, so it selects none of that project's Renovate merge requests.

What changes

  • Config reads dependency_bot_authors: [{id, username}] with the parser excluded_auto_merge_authors already uses, so the shape and error messages are the same. That parser is now shared, as parse_accounts. Project#dependency_bot_author?(id) matches on the ID. Two entries are refused: a list in a project that names bot_dependency under no scopes, low_scopes or auto_merge, where it would do nothing, and an entry for @gitlab-dependency-update-bot itself, which would drop one of that bot's two labels.
  • MrApprovalFlow.bot_authored_dependency_update? is one rule: a trusted author, and the labels asked of that author. 8420142 is asked for both labels, as it is today. An author the project lists is asked only for maintenancedependency. The change only adds: a project with no list behaves as it does today, gitlab-org/gitlab included. Eligibility reads the same method for low_scopes and auto_merge, so a listed bot is also approved, and set to merge, where a project names bot_dependency there.
  • Why automation:bot-authored is not asked of a listed bot: the daily hygiene policy gitlab-org:label-bot-authored-mrs adds it, after Renovate has opened the merge request. On release-platform-canary that was about 21 hours later on !298 (closed), and !290 (merged), !291 (merged) and !294 (merged) merged within an hour of opening, before it arrived.
  • TriggerReview: for a listed author's merge request, the label that brings it into bot_dependency is maintenancedependency alone. When automation:bot-authored arrives later, it does not start the flow a second time on a diff it has already rated, and ReconcileApproval does not decide again on it either.
  • A recreated access token is not reported. Rotating a project access token keeps its bot user. Recreating one makes a new bot user, with a new ID and username, which the list does not match. bot_dependency then stops taking that bot's merge requests, and nothing signals it: the project's maintainers see their Renovate merge requests going unrated, and the entry needs the new ID. An earlier version of this MR reported it to Sentry from a ReportUnlistedDependencyBot processor. That was removed in review, because nobody was set to watch the report.
  • Docs: the config file's header documents the key, the wider bot_dependency and where a listed bot counts. It also says a recreated access token's entry needs the new ID. TriggerReview#documentation covers the scope.

Why trust by ID

  • triage-ops already trusts automation by known ID: bot_dependency's author check is one.
  • Any developer can add maintenancedependency.
  • A project_<id>_bot_* pattern would match every token bot in a project.
  • The ID survives a token rotation, and a recreated token makes the flow stop trusting rather than start trusting someone else.

Compliance

Once a project names bot_dependency under low_scopes or auto_merge, this list decides whose merge requests gitlab-bot approves and sets to merge, so it is approval configuration.

  • gitlab-org/gitlab#638502 row 3 asks for CODEOWNERS and access controls on this file.
  • Row 4 asks for a post-merge review where no human merges.

A recreated token fails closed: the list stops matching, so nothing is approved or set to merge for the new bot until its ID is added. No report backs the list, so review of this file is what keeps it right.

Neither blocks a label-only project like release-platform-canary, where nothing approves.

How to set up and validate locally

SIMPLECOV=0 bundle exec rspec spec/processor/mr_approval_flow spec/processor/mr_approval_flow_spec.rb

New coverage:

  • config_spec.rb: parsing, matching by ID, freezing, every malformed shape excluded_auto_merge_authors already refuses, a list in a project that names bot_dependency nowhere, and the dependency update bot listed.
  • mr_approval_flow_spec.rb: both paths of the check, the dependency update bot still needing both labels in a project that lists another, and the author rather than the actor being what counts.
  • trigger_review_spec.rb: a listed bot starts the flow on opening; the late label does not start it again; another bot of the same project is out of scope, and the author is not looked up to decide it.
  • eligibility_spec.rb: a listed bot's update is approved and set to merge on maintenancedependency alone, the merge held to deps and tooling; another account with the same label is refused.
  • reconcile_approval_spec.rb: the late automation:bot-authored starts no decision on a listed bot's merge request.

🤖 Generated with Claude Code

Edited by Connor Sanders

Merge request reports

Loading
Loading