Copilot commented on code in PR #7741:
URL: https://github.com/apache/texera/pull/7741#discussion_r3809057205
##########
frontend/src/app/workspace/service/notebook-migration/notebook-migration.service.ts:
##########
@@ -163,6 +163,23 @@ export class NotebookMigrationService {
}
}
+ // Remove a workflow's notebook file from the Jupyter pod. Takes a concrete
wid so it can
+ // never fall back to the shared default filename and delete the wrong file;
callers guard
+ // out unsaved workflows before calling. Best effort by design: the database
rows are the
+ // source of truth for whether a workflow has a notebook, so a failure here
is logged, not
+ // surfaced, and nothing acts on the outcome.
+ public async deleteNotebookForWorkflow(wid: number): Promise<void> {
+ if (!this.enabled) return;
Review Comment:
`wid: number` does not exclude the unsaved sentinel `0`, and
`notebookFileName(0)` resolves to the shared `notebook.ipynb`. The
single-dashboard delete path only rejects `undefined`, so a zero-valued entry
could delete the wrong file. Reject non-positive/non-integer IDs here (and
cover `0` in the spec) before deriving the filename.
##########
notebook-migration-service/src/main/scala/org/apache/texera/service/resource/NotebookMigrationResource.scala:
##########
@@ -251,6 +234,62 @@ object NotebookMigrationResource extends LazyLogging {
}
}
+ // Delete the notebook file from Jupyter's work/ directory:
+ def deleteNotebook(body: String): Response = {
+ var conn: HttpURLConnection = null
+ try {
+ val json = mapper.readTree(body)
+
+ // Read the name defensively
+ val notebookName =
+
Option(json.get("notebookName")).filter(_.isTextual).map(_.asText()).getOrElse("")
Review Comment:
Malformed JSON is client input, but `readTree` throws into the generic
handler and this endpoint returns 500 (the new spec now codifies that result).
This misclassifies bad requests as service failures and can trigger
server-error monitoring/retries. Return `BAD_REQUEST` for parse failures or a
missing/non-object root, and update the malformed-body expectation accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]