Skip to content

fix(sdk): keep local dataset state when a delete request fails - #4633

Open
inchang-ing wants to merge 2 commits into
traceloop:mainfrom
inchang-ing:fix/dataset-delete-failure-keeps-state
Open

inchang-ing wants to merge 2 commits into
traceloop:mainfrom
inchang-ing:fix/dataset-delete-failure-keeps-state

Conversation

@inchang-ing

@inchang-ing inchang-ing commented Oct 18, 2026 •

Copy link
Copy Markdown

Fixes #4630.

HTTPClient.delete() returns False when the request fails: it logs the error and does not raise. Column.delete() and Row.delete() however only raise when the result is None:

result = self._http.delete(...)
if result is None:
    raise Exception(f"Failed to delete ...")

False is None is False, so a failed DELETE returned normally. The methods then removed the column/row from dataset.columns / dataset.rows, deleted the column's values from every row, and set deleted = True, even though the object still exists on the server.

Change

Both checks now use if not result, which matches the bool return type of HTTPClient.delete() and the existing Datasets.delete_by_slug() (if not success).

Tests

Added tests/datasets/test_delete_failure.py, which mocks requests.delete with a 503 response and asserts that:

  • Column.delete() raises and leaves dataset.columns, column.deleted and the row values unchanged;
  • Row.delete() raises and leaves dataset.rows and row.deleted unchanged.

Both tests fail on main and pass with the change. ruff check passes; the rest of tests/datasets/ has the same 16 network/cassette failures before and after this change in this environment.

Summary by CodeRabbit

  • Bug Fixes
    • Failed attempts to delete dataset columns or rows are now reported as errors when the server returns an unsuccessful or otherwise empty response.
    • If deletion fails, the affected data remains available locally and is not marked as deleted. Column values are also preserved. This helps ensure that a failed server-side deletion does not appear successful in the local dataset.

@CLAassistant

CLAassistant commented Oct 18, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 67290e20-d990-4dfe-8604-dec7feec7c5f
📥 Commits

Reviewing files that changed from the base of the PR and between 92925a7 and d400a36.

📒 Files selected for processing: 2
  • packages/traceloop-sdk/traceloop/sdk/datasets/column.py
  • packages/traceloop-sdk/traceloop/sdk/datasets/row.py

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

📝 Walkthrough

Column and row deletion now treat any falsy HTTP delete result as a failure. Tests verify that failed deletions raise resource-specific exceptions and preserve the corresponding local dataset state.

Changes: Dataset delete failure handling

Layer / File(s) Summary
Delete checks and regression tests
packages/traceloop-sdk/traceloop/sdk/datasets/column.py, packages/traceloop-sdk/traceloop/sdk/datasets/row.py, packages/traceloop-sdk/tests/datasets/test_delete_failure.py
Column.delete and Row.delete now raise failures for falsy delete results. Tests check the exception messages and confirm that failed deletions preserve the column, row, and row value.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: nina-kollman

Merge Risk: ⚪ Minimal · up to d400a

The PR preserves local dataset state when column or row deletion requests fail, with no remaining merge-blocking issue identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preserving local dataset state when a delete request fails.
Linked Issues check Passed Issue #4630 requires failed column and row deletes to raise and preserve local rows, columns, and values. Column.delete() and Row.delete() now treat a false HTTP result as failure before changing …
Out of Scope Changes check Passed The changes are limited to the two delete-result checks and focused regression tests. These changes directly support issue #4630. No unrelated change is established.
Full details: Linked Issues check

Explanation

Issue #4630 requires failed column and row deletes to raise and preserve local rows, columns, and values. Column.delete() and Row.delete() now treat a false HTTP result as failure before changing local state. tests/datasets/test_delete_failure.py covers a mocked 503 response for both methods and checks the required state.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

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 Report: Failed dataset deletes still remove local rows and columns

2 participants