aglinxinyuan opened a new issue, #5042:
URL: https://github.com/apache/texera/issues/5042

   ### Root cause
   
   `amber/src/main/scala/org/apache/texera/workflow/LogicalLink.scala` declares 
only a *single* `@JsonCreator` overload that accepts raw `String` op-ids:
   
   ```scala
   @JsonCreator
   def this(
       @JsonProperty("fromOpId") fromOpId: String,
       fromPortId: PortIdentity,
       @JsonProperty("toOpId") toOpId: String,
       toPortId: PortIdentity
   ) = this(OperatorIdentity(fromOpId), fromPortId, OperatorIdentity(toOpId), 
toPortId)
   ```
   
   But `objectMapper.writeValueAsString` serializes `OperatorIdentity` as an 
*object* `{"id": "op-A"}` (its scalapb case-class shape), not as a raw string. 
Jackson dispatches deserialization to the only `@JsonCreator` it knows — the 
String overload — which then rejects the object value.
   
   ### Reproduce
   
   ```scala
   val original = LogicalLink(
     OperatorIdentity("op-A"), PortIdentity(0),
     OperatorIdentity("op-B"), PortIdentity(1)
   )
   val json = objectMapper.writeValueAsString(original)
   // json = {"fromOpId":{"id":"op-A"}, "fromPortId":..., 
"toOpId":{"id":"op-B"}, "toPortId":...}
   objectMapper.readValue(json, classOf[LogicalLink])
   // throws com.fasterxml.jackson.databind.exc.MismatchedInputException:
   //   Cannot deserialize value of type `java.lang.String` from Object value
   ```
   
   The current characterization is pinned in
   
[`LogicalLinkSpec`](https://github.com/apache/texera/blob/main/amber/src/test/scala/org/apache/texera/workflow/LogicalLinkSpec.scala)
   ("NOT round-trip through writeValueAsString …") so the asymmetry can't drift 
silently.
   
   ### Surface
   
   | Surface | Write → Read |
   | --- | --- |
   | Frontend-saved workflow JSON (`fromOpId: "op-A"`, string form) | works — 
String overload dispatched |
   | `objectMapper.writeValueAsString(link)` → `objectMapper.readValue(json, 
classOf[LogicalLink])` (object form) | **broken** — String overload rejects the 
object value |
   
   ### Before → after
   
   | | Before | After |
   | --- | --- | --- |
   | `treeToValue` from string-shaped JSON | ✅ | ✅ (unchanged) |
   | `writeValueAsString` → `readValue` round-trip | ❌ 
`MismatchedInputException` | ✅ |
   | Characterization test in `LogicalLinkSpec` | pinned asymmetry | needs to 
flip to a passing round-trip assertion alongside the fix |
   
   ### Proposed fix (pick one)
   
   1. Add a second `@JsonCreator` overload that accepts an object-shape 
`OperatorIdentity`, OR
   2. Annotate `fromOpId` / `toOpId` with a custom `@JsonDeserialize` that 
handles both shapes (string and `{"id": ...}`).
   
   ### Tracked by
   
   The asymmetry is currently characterized (not asserted as passing) in 
`LogicalLinkSpec` — see review thread in PR #4956. When the fix lands, that 
test must be flipped to assert a successful round-trip.
   
   ### Priority
   P3 - Low (no production data loss; serialization-path-only)
   


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