Skip to content

fix(sdk): raise on failed dataset row and column delete and keep local state - #4775

Draft
doronkopit5 wants to merge 1 commit into
mainfrom
heal/issue-4630-a1
Draft

doronkopit5 wants to merge 1 commit into
mainfrom
heal/issue-4630-a1

Conversation

@doronkopit5

@doronkopit5 doronkopit5 commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #4630

Root cause

`HTTPClient.delete` returns a bool and gives `False` on failure. `Row.delete` and `Column.delete` checked `result is None`, the failure check used for post/get/put. That check is never true for `False`, so a failed DELETE (for example a 403 or 503) skipped the raise. The local changes then ran anyway: the row or column was removed, `deleted` was set, and the column's values were removed from every row.

Change

`Row.delete` and `Column.delete` now check `if not result:` on the bool that `HTTPClient.delete` returns, the same way `Datasets.delete_by_slug` already does. A failed delete now raises before any local state changes.

I added tests that patch `HTTPClient.delete` and run on a local dataset fixture:
- **Failure (returns `False`):** the delete raises "Failed to delete column/row", and the column or row, `deleted` and the row values are left unchanged. Both failure tests failed with "DID NOT RAISE" before the fix.
- **Success (returns `True`):** the column or row is still removed, `deleted` is set, and the column's values are removed from the row.

The full `tests/datasets` suite passes (31 tests), and ruff and mypy are clean.

Behaviour changes: `Column.delete()` and `Row.delete()` now raise `Exception("Failed to delete column/row ...")` when the DELETE request fails, and the local dataset rows, columns and values stay as they were. Before, the call returned normally and the local state was changed.
Not addressed: none

Scope

  • slice 1 of 1
  • covers rows: 4 of 4 in rows

Out of scope:

  • Changing HTTPClient.delete to return None or raise, so all verbs share one failure contract: That is a wider API change to the shared client. The fix belongs in the two callers, as delete_by_slug already does.
  • Row.delete leaving deleted=False when the row is not in dataset.rows after a successful delete: A separate pre-existing quirk. The issue covers only failed requests.
  • Replacing print-based error reporting in HTTPClient with logging or typed exceptions: Not needed to fix the reported bug.
  • Recording cassettes for real failed DELETE responses: A recording cannot reliably produce a 503 or 403. The failure is mocked at HTTPClient.delete or requests.delete, as the issue's reproduction does.

Regression evidence

Each test below failed on the base commit and passes with this change, run offline in the heal harness:

  • traceloop-sdk:tests/datasets/test_columns_operations.py::test_column_delete_failure_keeps_local_state (failed before: assertion)
  • traceloop-sdk:tests/datasets/test_rows_operations.py::test_row_delete_failure_keeps_local_state (failed before: assertion)
  • Guard tests (pass before and after): traceloop-sdk:tests/datasets/test_columns_operations.py::test_column_delete_success_removes_local_state, traceloop-sdk:tests/datasets/test_rows_operations.py::test_row_delete_success_removes_local_state

Package suites: no new failures against the offline baseline.
Ruff: clean.
Mypy: clean.

Telemetry evidence

tests/datasets/test_columns_operations.py::test_column_delete_failure_keeps_local_state

no telemetry change

tests/datasets/test_rows_operations.py::test_row_delete_failure_keeps_local_state

no telemetry change

2 guard tests: telemetry unchanged

Review

`Row.delete` and `Column.delete` now check `if not result:` on the bool that `HTTPClient.delete` returns, which matches `Datasets.delete_by_slug`. A failed DELETE now raises before any local change. The columns test file has a failure test and a success test that check `deleted`, the dataset's column list and the row values. The rows test file has the same pair for `deleted` and the row list. Both failure tests fail on the base commit. The change touches no telemetry. The only gap is minor: the tests patch `HTTPClient.delete` itself, so they never run its `False` return on a real 503 or 403.

Before merging

  • CI green: Lint, Build Packages, Test Packages (3.10, 3.11, 3.12)
  • Approved by a maintainer other than the author
  • CodeRabbit review read

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Dataset columns and rows now report deletion failures consistently when the server does not confirm the request. Failed deletions leave the local dataset unchanged; confirmed deletions remove the item and update its local state. This prevents items from appearing deleted locally when the server has not completed the deletion.

@doronkopit5

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Row and column deletion now treats any falsy HTTP delete result as a failure. Added tests check that failed deletions preserve local state and successful deletions update the dataset and its associated values.

Changes: Dataset deletion

Layer / File(s) Summary
Deletion checks and state tests
packages/traceloop-sdk/traceloop/sdk/datasets/column.py, packages/traceloop-sdk/traceloop/sdk/datasets/row.py, packages/traceloop-sdk/tests/datasets/test_columns_operations.py, packages/traceloop-sdk/tests/datasets/test_rows_operations.py
Column.delete and Row.delete now raise an error for any falsy HTTP delete result. Tests verify that failure leaves local state unchanged and success updates local state.

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

Failed row and column deletes now raise an error and leave local dataset state unchanged, while successful deletes still update local state. No merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(sdk): raise on failed dataset row and column delete and keep local state" matches the main change. Row.delete and Column.delete now check the boolean result of HTTPClient.delete and rai…
Linked Issues check Passed Issue #4630 requires that failed dataset column and row deletes raise an error and leave local rows, columns, and values unchanged. At the reviewed head, Column.delete in column.py calls `self._ht…
Out of Scope Changes check Passed The code changes are limited to the two delete callers, column.py and row.py, and the associated dataset test files. Each change implements the #4630 objective directly. The PR description exclude…
Full details: Title check

Explanation

The title "fix(sdk): raise on failed dataset row and column delete and keep local state" matches the main change. Row.delete and Column.delete now check the boolean result of HTTPClient.delete and raise on False before local state changes. The title names the fix, the affected methods, and the intended behavior. It is a single, specific sentence and does not use vague terms.

Full details: Linked Issues check

Explanation

Issue #4630 requires that failed dataset column and row deletes raise an error and leave local rows, columns, and values unchanged. At the reviewed head, Column.delete in column.py calls self._http.delete(...) and raises Exception("Failed to delete column ...") when the result is falsy, before it removes the column, sets deleted, or deletes row values. Row.delete in row.py applies the same if not result: check before it removes the row or sets deleted. This matches the False return of HTTPClient.delete that the issue describes. The success path still removes the object and its values. The summary reports two failure tests and two success tests in tests/datasets/test_columns_operations.py and tests/datasets/test_rows_operations.py. I did not read the test files directly, so the test coverage claim rests on the PR summary and description. The tests mock HTTPClient.delete, so they do not cover a real 403 or 503 response path through requests. This gap does not change the code-level compliance with the issue.

Full details: Out of Scope Changes check

Explanation

The code changes are limited to the two delete callers, column.py and row.py, and the associated dataset test files. Each change implements the #4630 objective directly. The PR description excludes the shared HTTPClient.delete contract change, the successful-delete deleted=False quirk, logging changes, and cassette recording. The reviewed code does not include these changes in the two caller files. The telemetry section in the PR description is a generated record and is not a code change. I did not read the test file diffs directly, so the scope of the test edits is based on the summary.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • 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: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 23c5d53e-fd51-4eeb-a511-35f06ac10ae5
Commits

Reviewing files that changed from the base of the PR and between b870d8a and 3ccc724.

Files selected for processing: 4

  • packages/traceloop-sdk/tests/datasets/test_columns_operations.py
  • packages/traceloop-sdk/tests/datasets/test_rows_operations.py
  • 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; 4 remain after this review.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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

1 participant