Repository navigation
Closed as not planned
Labels
Description
Problem
Current backend DELETE endpoint returns HTTP 500 error when attempting to delete a non-existent node. This violates REST/HTTP best practices for idempotent operations.
Current Behavior:
# First delete
DELETE /api/nodes/{id} → HTTP 200 OK
# Second delete (node already gone)
DELETE /api/nodes/{id} → HTTP 500 Internal Server Error
Error: "Node not found: {id}"Expected Behavior (REST standard):
# First delete
DELETE /api/nodes/{id} → HTTP 204 No Content
# Second delete (idempotent)
DELETE /api/nodes/{id} → HTTP 204 No ContentWhy This Matters
1. Network Reliability
- HTTP timeouts may cause clients to retry DELETE requests
- Double-DELETE scenario: request succeeds but client times out → retry fails with 500
- Non-idempotent DELETE breaks retry logic
2. Distributed Systems (Future)
- Distributed systems require idempotent operations for consistency
- Multiple servers may issue same DELETE command
- Current implementation causes errors in distributed scenarios
3. REST/HTTP Standards
- HTTP RFC 7231 mandates DELETE idempotence
- All standard HTTP libraries expect idempotent DELETE
- Violating standards causes integration issues
4. Developer Experience
- Developers expect standard REST behavior
- Current behavior requires special error handling
- Non-standard APIs are harder to learn and debug
Acceptance Criteria
- DELETE /api/nodes/{id} returns HTTP 204 for existing nodes
- DELETE /api/nodes/{id} returns HTTP 204 for non-existent nodes (idempotent)
- No error thrown when deleting already-deleted node
- Updated tests verify idempotence behavior
- Documentation updated to reflect idempotent DELETE
Technical Implementation
Backend Changes Required
File: packages/desktop-app/src-tauri/src/dev_server/node_endpoints.rs
async fn delete_node(
State(state): State<AppState>,
Path(id): Path<String>,
) -> Result<StatusCode, HttpError> {
// Try to delete node
let result = state.node_service.delete_node(&id).await;
match result {
Ok(_) => {
tracing::debug!("✅ Deleted node: {}", id);
Ok(StatusCode::NO_CONTENT) // 204
},
Err(e) if is_not_found_error(&e) => {
// Idempotent: node already deleted or never existed
tracing::debug!("✅ Delete idempotent (node doesn't exist): {}", id);
Ok(StatusCode::NO_CONTENT) // 204
},
Err(e) => {
// Actual error (permissions, database issue, etc.)
Err(HttpError::from_anyhow(e.into(), "NODE_SERVICE_ERROR"))
}
}
}Related Issues
- Issue Phase 2: Infrastructure Test Coverage (Sections 6-8, 21 tests) #211 - Phase 2 test coverage (identified this technical debt)
- Issue Bug: Database locking error when deleting nodes with inline mentions #190 - Database locking race condition (may interact with DELETE behavior)
Priority
Medium - Not blocking current Phase 2 work, but should be fixed before Phase 3.
Activity
refactor: Apply all code review improvements to database persistence …
feat: Session 3 - Section 7: Database Persistence Tests (9 tests, 100…
feat: Session 4 - Section 8: Event System Tests (6 tests, 100% passing)
Session 4: Complete Phase 2 Event System Tests (Issue #211 - Section …
malibio commentedon Dec 4, 2025
Test Baseline - Issue #219
Frontend: 729 tests passed
Rust: 54 tests passed
Starting implementation for idempotent DELETE endpoint.
malibio commentedon Dec 4, 2025
Issue Already Resolved
After investigation, this issue has already been addressed through architectural changes:
dev-proxy.rs (Browser Mode)
Tauri Commands (Desktop App)
delete_node_with_occwhich returnsDeleteResult { existed: bool }existed: falseNodeService Layer
delete_node()(line 2317-2320): Documented as idempotentdelete_node_with_occ()(line 2430): ReturnsDeleteResult { existed: false }for non-existentTests
test_delete_node_cascade_atomic_idempotentin surreal_store.rs verifies behaviorAll acceptance criteria are met. Closing as already implemented.
malibio commentedon Dec 4, 2025
Closing as already implemented - see comment above for details.
feat: Session 3 - Section 7: Database Persistence Tests (9 tests, 100…
Session 4: Complete Phase 2 Event System Tests (Issue #211 - Section …
feat: Session 3 - Section 7: Database Persistence Tests (9 tests, 100…
Session 4: Complete Phase 2 Event System Tests (Issue #211 - Section …
feat: Session 3 - Section 7: Database Persistence Tests (9 tests, 100…
Session 4: Complete Phase 2 Event System Tests (Issue #211 - Section …