fix: add cancel API for BulkImport (#3292) - #3440
Open
AquaticAzelf wants to merge 1 commit into
Open
Conversation
Add BulkImport.cancel() to support POST /bulk_imports/:id/cancel per GitLab docs https://docs.gitlab.com/api/bulk_imports/#cancel-a-migration. Mirrors ProjectPipeline.cancel pattern, uses GitlabCancelError and cli.register_custom_action, verified with responses mock and pytest. Closes python-gitlab#3292
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3440 +/- ##
==========================================
- Coverage 95.78% 95.76% -0.03%
==========================================
Files 100 100
Lines 6172 6181 +9
==========================================
+ Hits 5912 5919 +7
- Misses 260 262 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Fixes #3292.
Problem
API
POST /bulk_imports/:id/canceldocumented at https://docs.gitlab.com/api/bulk_imports/#cancel-a-migration was missing inBulkImportmodel (gitlab/v4/objects/bulk_imports.py:17). No way to cancel a migration via python-gitlab.Solution
gitlab/v4/objects/bulk_imports.py:1-39— add importstyping.Any,requests,gitlab.cli,gitlab.exceptions, and new method:Mirrors
ProjectPipeline.cancel(gitlab/v4/objects/pipelines.py:67-80), single file, 15 lines, no cross-folder changes. Uses existingGitlabCancelError(no new exception).Verification (folder-local only, no global installs)
C:\Users\Azelf\AppData\Local\Temp\opencode\python-gitlab-fix,python -m venv .venv,pip install -e .(folder-local),pip install responses pytestpytest tests/unit/objects/test_bulk_imports.py -v→ 6 passedBulkImport.cancelexists, CLIbulk-import cancelregistered.Stars: 2472★ (not zero), updated 2026, no duplicate PR (checked
closed_by_pull_requests).Closes #3292