Skip to content

fix: delete_variable endpoint also deleting resource#8245

Closed
wendrul wants to merge 1 commit intomainfrom
fix-variable-resource-delete
Closed

fix: delete_variable endpoint also deleting resource#8245
wendrul wants to merge 1 commit intomainfrom
fix-variable-resource-delete

Conversation

@wendrul
Copy link
Contributor

@wendrul wendrul commented Mar 5, 2026

No description provided.

@cloudflare-workers-and-pages
Copy link

Deploying windmill with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5cc3928
Status: ✅  Deploy successful!
Preview URL: https://311da36f.windmill.pages.dev
Branch Preview URL: https://fix-variable-resource-delete.windmill.pages.dev

View logs

@wendrul wendrul marked this pull request as draft March 5, 2026 17:07
@claude
Copy link
Contributor

claude bot commented Mar 5, 2026

Claude finished @wendrul's task in 1m 8s —— View job


Review of PR #8245

  • Gather context and read changed files
  • Analyze the change
  • Provide review feedback

Summary

This PR removes the explicit DELETE FROM resource query from the delete_variable function. The change is straightforward — 7 lines removed, no lines added.

Analysis

The fix looks correct. The delete_variable endpoint was deleting the associated resource with the same path, which is undesirable since variables and resources are independent entities that happen to share a path. Deleting a variable should not cascade to deleting the linked resource.

Issue: Inconsistency with delete_variables_bulk

The delete_variables_bulk function at backend/windmill-store/src/variables.rs:620-626 still explicitly deletes resources:

sqlx::query!(
    "DELETE FROM resource WHERE path = ANY($1) AND workspace_id = $2",
    &deleted_paths,
    w_id
)
.execute(&mut *tx)
.await?;

If the intent is that deleting a variable should not delete the associated resource, then this same deletion should be removed from the bulk delete path as well. Otherwise the behavior is inconsistent: single delete preserves the resource, but bulk delete removes it.

Verdict

The change itself is correct and clean. However, the same fix should be applied to delete_variables_bulk for consistency.


Testing Instructions

Navigate to the Variables page in a workspace. Create a variable (e.g. u/admin/test_var) and note that a linked resource with the same path exists (visible in the Resources page). Delete the variable using the delete action on the Variables page, then verify on the Resources page that the linked resource was not deleted. Also test bulk deletion of variables (select multiple variables and delete) to confirm the same behavior — currently bulk delete will still remove the resource, which is the inconsistency noted above.

@wendrul wendrul closed this Mar 5, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant