Skip to content

Extend deletion guards to all non-archived versions and add bulk-archive action#3198

Closed
claude[bot] wants to merge 1 commit into
mainfrom
claude/issue-3197-20260422-0552
Closed

Extend deletion guards to all non-archived versions and add bulk-archive action#3198
claude[bot] wants to merge 1 commit into
mainfrom
claude/issue-3197-20260422-0552

Conversation

@claude

@claude claude Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Product Description

When a service provider, assistant, pipeline, or collection is deleted, the UI now correctly blocks deletion if any non-archived experiment version references the object — including non-working, non-published snapshot versions that were previously silently ignored.

The "Cannot delete" modal now also shows a "Archive All Non-published Versions" button for non-working, non-published versions, so users can bulk-archive those references in one click instead of navigating to each version manually. Working and published versions still require manual cleanup.

Technical Description

  • Added is_blocking_object(obj) and is_bulk_archiveable(obj) helpers in apps/utils/deletion.py

    • is_blocking_object: any non-archived object blocks deletion
    • is_bulk_archiveable: non-working (working_version_id is set), non-published (is_default_version=False), non-archived — eligible for the bulk action
  • Updated get_related_experiments_queryset / get_related_experiments_with_pipeline_queryset in apps/assistants/models.py and apps/documents/models.py to return all non-archived versions (not only working/published)

  • Updated every delete view (apps/service_providers/views.py, apps/assistants/views.py, apps/documents/views.py, apps/pipelines/views.py) to:

    • Categorise blocking refs as manual-only (working + published) vs bulk-archiveable
    • Pass bulk_archiveable_experiments / bulk_archiveable_ids / bulk_archive_url to the modal template
  • Added bulk_archive_experiment_versions view (POST experiments/versions/bulk-archive/) that atomically archives a list of non-working, non-published versions scoped to the team

  • Updated templates/generic/referenced_objects.html to render a "Non-published versions" section with the bulk-archive form when applicable

Migrations

  • The migrations are backwards compatible

No migrations — only logic changes.

Demo

  1. Create an experiment with a service provider, create snapshot versions (v2, v3) referencing it
  2. Attempt to delete the service provider → modal now lists working/published versions under "Manual cleanup" and v2/v3 under "Non-published versions (can be bulk-archived)"
  3. Click "Archive All Non-published Versions" → v2 and v3 are archived, page refreshes
  4. If no other references remain, the service provider can now be deleted

Docs and Changelog

  • This PR requires docs/changelog update

Closes #3197

🤖 Generated with Claude Code

… action

Working and published experiment versions already blocked deletion of referenced
service providers, assistants, pipelines, and collections. Non-published snapshot
versions (not working, not published, not archived) were silently ignored, letting
deletions corrupt those references.

Changes:
- Add `is_blocking_object` / `is_bulk_archiveable` helpers in `apps/utils/deletion.py`
- Update `get_related_experiments_queryset` methods in assistants, documents, and
  service-provider views to return ALL non-archived versions, not just working/published
- Categorise blocking references in every delete view into "manual-only" (working +
  published) and "bulk-archiveable" (non-working, non-published, non-archived)
- Add `bulk_archive_experiment_versions` endpoint (`experiments:bulk_archive_versions`)
  that archives a supplied list of non-working, non-published versions atomically
- Update `templates/generic/referenced_objects.html` to show the bulk-archive section
  with a form button when bulk-archiveable versions exist
- Add comprehensive tests for deletion blocking and bulk-archive endpoint

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SmittieC

SmittieC commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@claude update this branch to resovle the conflicts

@claude

claude Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Claude finished @SmittieC's task in 7m 49s —— View job


Update branch to resolve conflicts

  • Fetch latest origin/main and identify merge conflicts
  • Attempt to perform the merge
  • Resolve conflicts / commit / pushblocked by environment (see below)

⚠️ I can't complete this merge in the current environment

The PR is mergeable: false / mergeable_state: dirty. The branch is 1 commit ahead, 2070 commits behind main (merge base bf3fe206c), so a real 3‑way merge is required. I was unable to perform it because the tools I'd need are not permitted in this run:

Operation I need Result
git fetch --unshallow / git fetch origin ❌ requires approval (blocked)
git merge origin/main ❌ requires approval (blocked)
git rebase, git merge-tree, git merge-file, git read-tree, git write-tree, git commit-tree ❌ requires approval (blocked)

On top of that, the checkout is a shallow clone (origin/main is fetched at depth 1), so git merge-base can't even find the common ancestor locally, and I can't git fetch to unshallow it.

I also can't do this server‑side: GitHub's Update branch endpoint and POST /merges both refuse when there are real conflicts, and simply editing the branch files without a merge/rebase commit can't clear a genuine overlapping‑hunk conflict while preserving this PR's intent.

Only git add / git commit / git push (and read‑only git) are available to me here, which isn't enough to construct the merge commit.

Files that changed on both main and this branch (the conflict candidates)

apps/assistants/views.py
apps/documents/models.py
apps/documents/views.py
apps/experiments/urls.py
apps/experiments/views/__init__.py
apps/experiments/views/experiment.py
apps/pipelines/views.py
apps/service_providers/tests/test_views.py
apps/service_providers/views.py
apps/utils/deletion.py
templates/generic/referenced_objects.html

(apps/assistants/models.py changed only on this branch, so it should merge cleanly.)

How to resolve

Option A — locally (recommended):

git checkout claude/issue-3197-20260422-0552
git fetch origin
git merge origin/main
# resolve conflicts in the files above, then:
uv run pytest apps/service_providers/tests/test_views.py -v
git add -A && git commit && git push origin claude/issue-3197-20260422-0552

Option B — let me do it: re‑trigger me in an environment where git fetch and git merge are allowed and the repo is checked out with full history (not shallow), e.g. actions/checkout with fetch-depth: 0. I'll then perform and push the merge.

Sorry I couldn't push a fix directly this time — the restriction is on my available git tools, not on the code itself.
· branch claude/issue-3197-20260422-0552

@SmittieC

SmittieC commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Redid it here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend object-reference checks to non-published/non-working versions and add bulk-archive action

1 participant