Skip to content

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

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

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
Copy link
Copy Markdown
Contributor

@claude claude Bot commented Apr 22, 2026

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>
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

0 participants