Skip to content

Commit ed82e90

Browse files
Copilotintel352
andauthored
fix: return 404 on deploy/stop for non-existent workflow IDs (#137)
* Initial plan * fix: add 404 handling to deploy and stop workflow pipelines Co-authored-by: intel352 <77607+intel352@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
1 parent 06e8ec7 commit ed82e90

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

admin/config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,20 @@ workflows:
10371037
type: step.request_parse
10381038
config:
10391039
path_params: [id]
1040+
- name: check-exists
1041+
type: step.db_query
1042+
config:
1043+
database: admin-db
1044+
query: "SELECT id FROM workflows WHERE id = ?"
1045+
params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"]
1046+
mode: single
1047+
- name: check-found
1048+
type: step.conditional
1049+
config:
1050+
field: "steps.check-exists.found"
1051+
routes:
1052+
"false": not-found
1053+
default: set-now
10401054
- name: set-now
10411055
type: step.set
10421056
config:
@@ -1062,6 +1076,12 @@ workflows:
10621076
config:
10631077
status: 200
10641078
body_from: "steps.get-workflow.row"
1079+
- name: not-found
1080+
type: step.json_response
1081+
config:
1082+
status: 404
1083+
body:
1084+
error: "workflow not found"
10651085
# Stop: update workflow status to 'stopped'
10661086
- method: POST
10671087
path: "/api/v1/admin/workflows/{id}/stop"
@@ -1073,6 +1093,20 @@ workflows:
10731093
type: step.request_parse
10741094
config:
10751095
path_params: [id]
1096+
- name: check-exists
1097+
type: step.db_query
1098+
config:
1099+
database: admin-db
1100+
query: "SELECT id FROM workflows WHERE id = ?"
1101+
params: ["{{index .steps \"parse-request\" \"path_params\" \"id\"}}"]
1102+
mode: single
1103+
- name: check-found
1104+
type: step.conditional
1105+
config:
1106+
field: "steps.check-exists.found"
1107+
routes:
1108+
"false": not-found
1109+
default: set-now
10761110
- name: set-now
10771111
type: step.set
10781112
config:
@@ -1098,6 +1132,12 @@ workflows:
10981132
config:
10991133
status: 200
11001134
body_from: "steps.get-workflow.row"
1135+
- name: not-found
1136+
type: step.json_response
1137+
config:
1138+
status: 404
1139+
body:
1140+
error: "workflow not found"
11011141
# Load workflow from a server-local filesystem path
11021142
- method: POST
11031143
path: "/api/v1/admin/workflows/load-from-path"

0 commit comments

Comments
 (0)