Add API integration to fetch blocked versions at job construction#14917
Merged
Conversation
8c7af59 to
b5d414c
Compare
a74d6bb to
37b3dc0
Compare
b5d414c to
db2d4dd
Compare
37b3dc0 to
f682877
Compare
237ee63 to
4446560
Compare
f682877 to
f3936b1
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR wires a new updater-side integration to fetch globally managed “blocked versions” from dependabot-api at execution time (behind an experiment flag) and flow them into Dependabot::Job so they participate in the normal ignore/version filtering and logging paths.
Changes:
- Add
ApiClient#fetch_blocked_versions(package_manager)and expose it viaDependabot::Service. - Fetch blocked versions during
UpdateFilesCommand#jobconstruction whenExperiments.enabled?(:blocked_versions)and inject them into the job definition beforeJob.new_update_job. - Extend
Dependabot::Jobto carryblocked_versions, apply them as additional ignore requirements, and log matching blocked entries (plus add/extend specs).
Show a summary per file
| File | Description |
|---|---|
| updater/lib/dependabot/api_client.rb | Adds a new API call to retrieve blocked versions for a job. |
| updater/lib/dependabot/service.rb | Delegates fetch_blocked_versions to the API client. |
| updater/lib/dependabot/update_files_command.rb | Fetches/injects blocked versions at job construction time behind an experiment flag. |
| updater/lib/dependabot/job.rb | Adds blocked_versions to job attributes; applies/logs blocked version ignores. |
| updater/spec/dependabot/api_client_spec.rb | Adds unit tests for fetch_blocked_versions behavior. |
| updater/spec/dependabot/update_files_command_spec.rb | Adds tests for the job-construction-time fetch behavior. |
| updater/spec/dependabot/job_spec.rb | Adds tests for blocked versions being enforced/logged via job ignore logic. |
Copilot's findings
- Files reviewed: 7/7 changed files
- Comments generated: 3
kbukum1
commented
May 8, 2026
8347d57 to
bfaf2eb
Compare
8551485 to
fac5354
Compare
620a828 to
509752f
Compare
70017bb to
ca8424d
Compare
59057a7 to
02bf234
Compare
robaiken
reviewed
May 19, 2026
9014e61 to
0ffb8bf
Compare
robaiken
approved these changes
May 20, 2026
0ffb8bf to
bdce0a3
Compare
Implement the API call that fetches blocked versions from dependabot-api and injects them into the job definition before the Job object is constructed. Changes: - ApiClient#fetch_blocked_versions: GET endpoint that retrieves blocked versions for a given package manager. Gracefully handles errors (returns [] on failure, logs warning). - Service: delegate fetch_blocked_versions to client - UpdateFilesCommand#job: fetch blocked versions during job construction (gated behind :blocked_versions experiment flag) and inject into job_definition hash - Remove the TODO placeholder from previous PR Tests: - ApiClient spec: success, error, timeout, and empty response cases - UpdateFilesCommand spec: verifies fetch is called with correct package manager and handles empty responses Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Handle JSON::ParserError and validate data is an Array in fetch_blocked_versions - Deep-copy Environment.job_definition to avoid mutating the memoized global - Rename experiment flag from :blocked_versions to :dependabot_blocked_versions - Assert blocked versions are actually injected into the Job in tests - Add specs for invalid JSON and non-array data responses Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…riments - Validate parsed response is a Hash before calling fetch on it - Add test for non-object JSON body (e.g. bare array) - Pre-register experiments from job definition before the blocked_versions gate - Add test verifying experiment flag works when set via job definition Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…nore_conditions Align the blocked_versions data structure with ignore_conditions conventions and the dependabot-api BlockedDependency model which stores version requirement strings (e.g. '= 3.3.6', '>= 3.0, < 4.0') rather than bare versions. The API endpoint will transform from the model's 'version' field to 'version-requirement' in the response, matching how ignore_conditions uses 'version-requirement' throughout the stack. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update bin/dry-run.rb (from merged PR #14916) to use 'version-requirement' instead of 'version' in the blocked_versions data structure, matching the rename done in job.rb and the API contract. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bdce0a3 to
396e50b
Compare
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What are you trying to accomplish?
Add the API client integration that fetches blocked versions from the API and injects them into the job definition at construction time. Blocked versions are globally managed (not per-job configuration), so they need to be fetched fresh at execution time. This ensures the updater always uses the latest blocked versions list.
This PR also renames the blocked versions field from
versiontoversion-requirementto align withignore_conditionsconventions and the API endpoint contract.Stacks on #14915 which adds the
blocked_versionsattribute to the Job class.Anything you want to highlight for special attention from reviewers?
Experiments.enabled?(:dependabot_blocked_versions)— no behavior change without the flag.JSON.parse(JSON.generate(...))) to avoid mutating the memoizedEnvironment.job_definition.version-requirementfield name matchesignore_conditionsconventions — the API endpoint transforms from the model'sversionfield toversion-requirementin the response.How will you know you've accomplished your goal?
api_client_spec.rb: 6 tests covering success, error, timeout, empty response, invalid JSON, non-object JSON, and non-array data.update_files_command_spec.rb: 3 tests covering fetch + inject, experiment flag via job definition, and empty response handling.job_spec.rb: All blocked versions test data updated to useversion-requirementfield name.dependabot_blocked_versionsexperiment is enabled, blocked versions will appear in updater logs as "Blocked versions (by GitHub Security)" for matching dependencies.Checklist