You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(sdk): raise on failed dataset row and column delete and keep local state - #4775
`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:
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.
`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)
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.
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.
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: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
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
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
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
inrowsOut of scope:
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)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_statePackage 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_stateno telemetry change
tests/datasets/test_rows_operations.py::test_row_delete_failure_keeps_local_stateno 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
🤖 Generated with Claude Code
Summary by CodeRabbit