Repository navigation
fix(amber): return 404 for unavailable public workflow - #9061
ShawnGarello wants to merge 3 commits into
Conversation
retrievePublicWorkflow dereferenced the row from fetchOne() without a null check, so a wid that does not exist or names a private workflow answered 500 with a NullPointerException. It now throws NotFoundException (404), the same guard getWorkflowType already has. Closes apache#8139 Generated-by: Claude Code (Opus 5.5)
|
/request-review @Yicong-Huang |
Backport auto-label reportThis
|
Automated Reviewer SuggestionsBased on the
|
Yicong-Huang
left a comment
There was a problem hiding this comment.
🟢 0 must-fix · 0 advisory · 0 polish: small, peer-consistent guard that returns 404 instead of 500 for unavailable public workflows.
Verification trace
Checked the changed public endpoint (GET /api/workflow/publicised/{wid}) against its sibling public endpoints: the IS_PUBLIC filter in the query is the access control, so private and missing workflows return the same 404 and no existence oracle is created, and wid reaches the database only through parameterized jOOQ. The other fetchOne() dereferences in the dashboard resources are guarded or non-nullable (Option-wrapped, getOrElse throwing NotFoundException, or INSERT ... RETURNING), so this was the only unguarded one.
|
Thanks @Yicong-Huang! @mengw15 @xuang7, could you decide on the release/v1.3 and release/v1.2 labels when you have a chance? |
|
Updated the branch now that #9100 fixed CI. @Yicong-Huang, could you approve the workflow runs when you have a chance? |
What changes were proposed in this PR?
Opening a hub link to a workflow that was deleted or made private makes
GET /api/workflow/publicised/{wid}fail with a 500.retrievePublicWorkflowdereferenced the row fromfetchOne()without a null check. It now answers 404, the same guardgetWorkflowTypealready has. A private workflow gets the same 404 as a missing one, as the query (wid = ? AND is_public) already treats them alike. The hub page shows the same load error either way; what changes is the status code, and the server log no longer gets aNullPointerExceptionstack trace.Two regression tests in
WorkflowResourceSpec, under their ownretrievePublicWorkflowsubject: a private workflow, and a wid that does not exist. The public case is already covered by the makePublic and default-view tests.This picks up #8140 by @carloea2, which was closed unmerged; it applies the review on that PR (braces, the test under its own subject, the title).
Any related issues, documentation, discussions?
Closes #8139
Backport: the same unguarded
fetchOne()is onrelease/v1.3andrelease/v1.2, but the code after it differs there (nopublicCopyOf), so the cherry-pick may need the guard re-applied by hand.WorkflowResourceSpec.scalaexists on both branches.How was this PR tested?
With Postgres up,
sbt -batch "WorkflowExecutionService/testOnly *WorkflowResourceSpec":NullPointerExceptioninstead ofNotFoundException.testOnly *WorkflowResourceSpec *WorkflowPublishSpec(the other spec that calls the method): 135 pass, 0 fail.NullPointerException.sbt scalafmtCheckAll "scalafixAll --check"is clean.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5.5)