Skip to content

Fix group deletion for single-artifact groups - #113

Open
sutharshikhar-gif wants to merge 1 commit into
dbpedia:mainfrom
sutharshikhar-gif:fix/cand2-single-artifact-group-deletion
Open

sutharshikhar-gif wants to merge 1 commit into
dbpedia:mainfrom
sutharshikhar-gif:fix/cand2-single-artifact-group-deletion

Conversation

@sutharshikhar-gif

@sutharshikhar-gif sutharshikhar-gif commented Nov 22, 2026 •

Copy link
Copy Markdown

Closes #112

Fixes group deletion when the Databus API returns databus:hasArtifact as a single JSON object instead of a list.

Previously, the deletion implementation expected a list of artifact dictionaries. When the API returned a single dictionary, iteration processed its keys instead of the artifact object, potentially causing an AttributeError.

This change normalizes the single-artifact response before processing it.

Changes

  • Normalize a single artifact dictionary into a list.
  • Preserve support for multiple artifacts.
  • Skip malformed non-dictionary artifact entries.
  • Validate artifact URIs before processing.
  • Add regression tests for single-artifact group deletion and relevant edge cases.

Tests

  • CAND-2 regression tests: 7 passed.
  • Full test suite: 207 passed, 3 skipped.
  • Ruff: All checks passed.
  • Python: 3.11.18.

Scope

Only the following files are changed:

  • databusclient/api/delete.py
  • tests/test_delete_group.py

No unrelated deployment changes are included.

Summary by CodeRabbit

  • Bug Fixes
    • Group deletion now handles artifact information provided as either a single item or a list. Missing or invalid artifact entries are safely skipped, while valid artifact references continue through the existing deletion process. This prevents unexpected artifact data from interrupting group deletion.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

_delete_group now accepts a single artifact object or a list of artifacts. It skips values and entries that do not contain a non-empty string @id. Tests cover supported artifact shapes and invalid values.

Changes: Group deletion

Layer / File(s) Summary
Normalize and validate artifact entries
databusclient/api/delete.py, tests/test_delete_group.py
_delete_group normalizes a single artifact object into a list and treats missing or unexpected values as no artifacts. It skips non-dictionary entries and entries without a non-empty string @id. Tests cover these cases and verify valid IDs are passed to deletion.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: integer-ctrl

Merge Risk: Minimal · up to 995bd

Group deletion now handles groups whose single artifact is returned as a JSON object, and it skips malformed entries. The change is small and tested, and no merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: group deletion now handles a group whose databus:hasArtifact is a single object. The changeset normalizes that single artifact into a list in databusclient/api/delete.…
Description check Passed The description follows the repository template. It links Issue #112, names the change type as a bug fix in the description text, and lists the changes, tests, and scope. The template's Type of change…
Linked Issues check Passed Issue #112 requires group deletion to handle three cases: a single artifact as a JSON object, multiple artifacts as a JSON array, and no artifacts. At the reviewed head, _delete_group in `databuscli…
Out of Scope Changes check Passed The PR changes databusclient/api/delete.py and tests/test_delete_group.py, as stated in the PR description. The delete.py changes are confined to the _delete_group artifact-normalization and U…
Full details: Title check

Explanation

The title names the main change: group deletion now handles a group whose databus:hasArtifact is a single object. The changeset normalizes that single artifact into a list in databusclient/api/delete.py and adds regression tests, so the title matches the primary fix.

Full details: Description check

Explanation

The description follows the repository template. It links Issue #112, names the change type as a bug fix in the description text, and lists the changes, tests, and scope. The template's Type of change checkboxes and most Checklist items are not ticked, and the description does not state the change type or confirm the checklist items explicitly. The described changes and the test evidence are specific.

Full details: Linked Issues check

Explanation

Issue #112 requires group deletion to handle three cases: a single artifact as a JSON object, multiple artifacts as a JSON array, and no artifacts. At the reviewed head, _delete_group in databusclient/api/delete.py wraps a dict databus:hasArtifact in a list. It passes a list through unchanged. It sets any missing, None, or other-typed value to an empty list. It then skips non-dictionary items and items whose @id is missing, non-string, or empty, before calling _delete_artifact on each remaining URI. This covers the proposed solution in #112. The PR summary reports regression tests in tests/test_delete_group.py for a single artifact dictionary, a list of artifacts, and the no-artifact and malformed-entry edge cases. Those tests were not read directly. The head source alone establishes the behavior. No unmet coding requirement was found.

Full details: Out of Scope Changes check

Explanation

The PR changes databusclient/api/delete.py and tests/test_delete_group.py, as stated in the PR description. The delete.py changes are confined to the _delete_group artifact-normalization and URI-collection logic that #112 addresses. The reviewed head shows no unrelated logic in that function. The added filter that skips versioned artifact URIs is described in the summary as continuing the existing version check, so it is not a new behavior. The whole-PR merge base blob could not be read, so the exact base-to-head diff was not verified directly. This limits confidence about whether the version filter is pre-existing, but the summary does not describe it as new.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e92a9ac1-3f30-438d-9c8e-b09b93c217ce
Commits

Reviewing files that changed from the base of the PR and between 70fb67f and 995bda9.

Files selected for processing: 2

  • databusclient/api/delete.py
  • tests/test_delete_group.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Group deletion fails when the group contains a single artifact

1 participant