Skip to content

fix(delete_project_file): use URL segment for path + refuse root deletes (prevents whole-project wipe)#14

Closed
arsyakaukabi wants to merge 1 commit into
cloudera:mainfrom
arsyakaukabi:fix/delete-project-file-path
Closed

fix(delete_project_file): use URL segment for path + refuse root deletes (prevents whole-project wipe)#14
arsyakaukabi wants to merge 1 commit into
cloudera:mainfrom
arsyakaukabi:fix/delete-project-file-path

Conversation

@arsyakaukabi
Copy link
Copy Markdown

Summary

Fixes the destructive bug reported in #13. delete_project_file was sending the target path as a ?path= query string, which the Cloudera AI Workbench v2 Files API silently ignores. The actual request was:

DELETE /api/v2/projects/{project_id}/files

i.e. delete the entire project file tree, recursively, regardless of which file_path the caller specified. The tool then reported success: true because the server returned 200.

This has caused at least one real incident in production use (full project wipe via the MCP tool, recovered only via platform backup). Filing the fix as soon as the incident was contained.

Changes

  1. Send the path as a URL segment, matching the working download_project_file_v2 / patched list_project_files endpoints:

    delete_url = f"{host}/api/v2/projects/{project_id}/files/{encoded_file_path}"
  2. Refuse file_path values that normalize to the project root ("", "/", ".", ".."). Even with the URL fix in place, this tool should never target the project file root — adding the guard means a future regression in URL handling cannot reintroduce the catastrophic outcome.

Test plan

  • Manually confirmed the new URL shape against the Cloudera v2 API on livyatan.apps.slithereen.data.bri.co.id: deleting PLAYGROUND/<user>/scratch.txt now deletes only that file and leaves siblings intact.
  • Manually confirmed the guard: calls with file_path="", "/", ".", or ".." are now rejected before any HTTP request is sent.
  • Manually confirmed nested-path deletes still work end-to-end (a/b/c/file.txt).

Related

The Cloudera AI Workbench v2 Files API silently ignores ?path=...
query strings on the project files endpoint (same root cause as the
list_project_files bug, but with destructive consequences).

Before this fix, calling delete_project_file with any file_path was
effectively issuing:

  DELETE /api/v2/projects/{project_id}/files

i.e. delete the entire project file root, recursively. The tool then
reported success: true because the server returned 200, so callers
(including LLM clients) had no signal that anything was wrong.

This:

1. Switches the URL to a path-segment form, matching the working
   download / list endpoints:
     DELETE /api/v2/projects/{project_id}/files/<encoded path>
2. Refuses empty / root-equivalent file_path values up front, so even
   if a future regression brings back the wrong endpoint shape, this
   tool can never target the project root.

Fixes cloudera#13. See also cloudera#10 / cloudera#12 for the non-destructive sibling bug in
list_project_files.
@Khauneesh-AI
Copy link
Copy Markdown
Collaborator

Hi @arsyakaukabi — thank you for catching this and putting together the fix. The underlying issue (path
encoding + root delete guard) has been resolved in v2.0.0 via a complete migration to the official
cmlapi Python SDK, which handles URL construction and path encoding correctly.

The relevant fix landed in commit 56ee14d (DSE-54632) and was further solidified in b591376 where all
tools now use client.delete_project_file(project_id, path) — the SDK builds the correct URL
internally.

Closing this PR since the fix is now on main, but your bug report and repro were invaluable in
prioritizing this. For future contributions, please target the dev branch — see our contributing
workflow
.

Thanks again! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants