aglinxinyuan opened a new pull request, #7303:
URL: https://github.com/apache/texera/pull/7303

   ### What changes were proposed in this PR?
   
   `WorkflowWebsocketResource` was at **0%**. The endpoint is thin, but two 
parts of it are real logic nothing else guarded:
   
   - **The write-access gate on `WorkflowExecuteRequest`** — the only consumer 
of the privilege `myOnOpen` parses off the handshake. It must both report to 
the client *and* rethrow, so both halves are asserted; dropping either would 
leave the other silently missing. (Unreachable in single-node mode, where 
`ServletAwareConfigurator` hard-codes WRITE, but live under Kubernetes where 
the privilege comes from the `x-user-computing-unit-access` header.)
   - **The catch-all error mapper**, which stamps every failure as 
`COMPILATION_ERROR` with a placeholder operator and routes it to the socket 
when no execution exists.
   
   Six tests, driving a mocked `javax.websocket.Session` the way 
`CollaborationResourceSpec` does and registering a `SessionState` directly, so 
no real workflow is created.
   
   One detail worth calling out: the fatal-error `type` field is a **scalapb 
enum, and it serializes as an object rather than a string** —
   
   ```json
   "type": { "value": 0, "index": 0, "name": "COMPILATION_ERROR", ... }
   ```
   
   so the client reads `type.name`. The test pins that nested shape, because 
flattening it would break the frontend's error panel silently.
   
   **Every one of the six tests was shown to fail under a targeted production 
mutation**, all reverted afterwards (production diff empty):
   
   | Mutation | Result |
   |---|---|
   | neuter the write-access gate | red |
   | drop the `"Initializing"` announcement | red |
   | swallow the rethrow | red |
   | close the wrong session id | red |
   | answer a heartbeat with the wrong event | red |
   | (the first four together) | 5 of 6 red |
   
   Deliberately untested, each because it would pin an accidental failure 
rather than a contract: `myOnOpen`'s missing-parameter and bogus-privilege 
paths; `ModifyLogicRequest`, whose reconfiguration service is null until 
`executeWorkflow` has run; and `ResultPaginationRequest`, whose no-workflow 
case is a discarded `Option.foreach`.
   
   **Two findings recorded in comments rather than pinned:**
   
   1. `objectMapper.readValue` sits **outside** the try, so an unparseable 
frame escapes un-mapped and the client is told nothing.
   2. With a workflow attached but no execution, `executionService.getValue` 
returns null, so `workflowStateOpt.map(...)` yields `Some(null)` — which slips 
past the `case None` guard and NPEs instead of raising the intended "execution 
is not initialized".
   
   No production file is touched.
   
   ### Any related issues, documentation, discussions?
   
   Closes #7300
   
   ### How was this PR tested?
   
   Six new tests, run with the two specs that share the `SessionState` registry 
to confirm no interference — 25 tests, Java 17:
   
   ```
   sbt "WorkflowExecutionService/testOnly 
org.apache.texera.web.resource.WorkflowWebsocketResourceSpec 
org.apache.texera.web.SessionStateSpec 
org.apache.texera.web.resource.CollaborationResourceSpec"
   ```
   
   ```
   [info] Suites: completed 3, aborted 0
   [info] Tests: succeeded 25, failed 0, canceled 0, ignored 0, pending 0
   [info] All tests passed.
   ```
   
   `Test/scalafmtCheck` and `Test/scalafix --check` both `[success]`.
   
   ### Was this PR authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Code (Opus 5)
   
   


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