Copilot commented on code in PR #5729:
URL: https://github.com/apache/texera/pull/5729#discussion_r3425764477
##########
workflow-compiling-service/src/main/scala/org/apache/texera/amber/compiler/model/LogicalLink.scala:
##########
@@ -20,22 +20,58 @@
package org.apache.texera.amber.compiler.model
import com.fasterxml.jackson.annotation.{JsonCreator, JsonProperty}
+import com.fasterxml.jackson.databind.JsonNode
import org.apache.texera.amber.core.virtualidentity.OperatorIdentity
import org.apache.texera.amber.core.workflow.PortIdentity
+object LogicalLink {
+ private def readOperatorIdentity(node: JsonNode, fieldName: String):
OperatorIdentity = {
+ if (node == null || node.isNull) {
+ OperatorIdentity(null)
+ } else if (node.isTextual) {
+ OperatorIdentity(node.asText())
+ } else if (node.isObject) {
+ val idNode = node.get("id")
+ if (idNode == null || idNode.isNull) {
+ OperatorIdentity(null)
+ } else {
+ OperatorIdentity(idNode.asText())
+ }
+ } else {
Review Comment:
`readOperatorIdentity` currently treats `{ "id": <non-string> }` as valid
and coerces it with `asText()` (e.g., numeric id becomes "123"). If this helper
is meant to reject malformed nodes (as described), it should require `id` to be
textual when present, and throw otherwise (while still allowing missing/null
`id` to map to `OperatorIdentity(null)` for leniency).
##########
amber/src/main/scala/org/apache/texera/workflow/LogicalLink.scala:
##########
@@ -20,9 +20,31 @@
package org.apache.texera.workflow
import com.fasterxml.jackson.annotation.{JsonCreator, JsonProperty}
+import com.fasterxml.jackson.databind.JsonNode
import org.apache.texera.amber.core.virtualidentity.OperatorIdentity
import org.apache.texera.amber.core.workflow.PortIdentity
+object LogicalLink {
+ private def readOperatorIdentity(node: JsonNode, fieldName: String):
OperatorIdentity = {
+ if (node == null || node.isNull) {
+ OperatorIdentity(null)
+ } else if (node.isTextual) {
+ OperatorIdentity(node.asText())
+ } else if (node.isObject) {
+ val idNode = node.get("id")
+ if (idNode == null || idNode.isNull) {
+ OperatorIdentity(null)
+ } else {
+ OperatorIdentity(idNode.asText())
+ }
+ } else {
Review Comment:
`readOperatorIdentity` accepts an object-shaped op id with a non-textual
`id` field (e.g., `{ "id": 123 }`) and will silently coerce it via `asText()`
("123"), which contradicts the stated goal of rejecting malformed nodes and can
mask bad input. Consider validating that `id` is either null/missing or a
textual node, and throw otherwise (ideally mentioning `fieldName.id` in the
message).
--
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]