Copilot commented on code in PR #7132:
URL: https://github.com/apache/texera/pull/7132#discussion_r3685855059


##########
notebook-migration-service/src/main/scala/org/apache/texera/service/resource/NotebookMigrationResource.scala:
##########
@@ -374,6 +381,46 @@ object NotebookMigrationResource extends LazyLogging {
           .build()
     }
   }
+
+  // Delete notebook + mapping for a workflow. The notebook -> 
workflow_notebook_mapping FK is
+  // ON DELETE CASCADE, so deleting the notebook row removes its mapping rows 
too. notebook.wid
+  // is UNIQUE (one notebook per workflow), so wid alone identifies the row 
and vid is not needed.
+  def deleteNotebookAndMapping(body: String, uid: java.lang.Integer): Response 
= {
+    try {
+      val json = mapper.readTree(body)
+
+      val wid: java.lang.Integer = json.get("wid").asInt()

Review Comment:
   `wid` is read via `json.get("wid").asInt()` without validating the field 
exists and is an integer. If the JSON body omits `wid`, `json.get("wid")` is 
null and this will throw (500). If `wid` is a non-integer (e.g., string), 
`asInt()` coerces to 0, which is likely unintended. Consider returning 400 Bad 
Request with a clear error when `wid` is missing/invalid.



-- 
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]

Reply via email to