feat: decompose V1 CRUD routes into pipeline primitives (#86)#123
feat: decompose V1 CRUD routes into pipeline primitives (#86)#123
Conversation
Replace 6 V1 admin CRUD routes that delegated to V1APIHandler with
declarative pipeline definitions using admin-db:
- POST /api/v1/admin/organizations/{id}/projects (create project)
- POST /api/v1/admin/projects/{id}/workflows (create workflow in project)
- POST /api/v1/admin/workflows (create workflow)
- PUT /api/v1/admin/workflows/{id} (update workflow + version)
- POST /api/v1/admin/workflows/{id}/deploy (deploy workflow)
- POST /api/v1/admin/workflows/{id}/stop (stop workflow)
Each route now uses pipeline steps (request_parse, validate, set,
db_exec, db_query, conditional, json_response) instead of Go delegates.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR completes Phase B of the admin config decomposition by replacing the remaining V1 admin workflow deploy and stop CRUD routes that previously delegated to admin-v1-mgmt with fully declarative pipeline definitions backed by admin-db.
Changes:
- Replaced
/api/v1/admin/workflows/{id}/deploydelegate step with a pipeline that updates status toactiveand returns the workflow record. - Replaced
/api/v1/admin/workflows/{id}/stopdelegate step with a pipeline that updates status tostoppedand returns the workflow record.
| - name: respond | ||
| type: step.json_response | ||
| config: | ||
| status: 200 | ||
| body_from: "steps.get-workflow.row" |
There was a problem hiding this comment.
The stop pipeline responds 200 with steps.get-workflow.row even when the workflow isn't found. Because step.db_query (mode: single) returns found: false + empty row, this endpoint will return {} with 200 rather than a 404.
Add a conditional step on steps.get-workflow.found (or check affected_rows from the UPDATE) and return a 404 json_response when the workflow does not exist.
| - name: respond | |
| type: step.json_response | |
| config: | |
| status: 200 | |
| body_from: "steps.get-workflow.row" | |
| - name: respond-if-found | |
| type: step.condition | |
| config: | |
| condition: "{{index .steps \"get-workflow\" \"found\"}}" | |
| true_steps: | |
| - name: respond | |
| type: step.json_response | |
| config: | |
| status: 200 | |
| body_from: "steps.get-workflow.row" | |
| false_steps: | |
| - name: respond-not-found | |
| type: step.json_response | |
| config: | |
| status: 404 | |
| body: | |
| error: "workflow not found" |
| mode: single | ||
| - name: respond | ||
| type: step.json_response |
There was a problem hiding this comment.
The deploy pipeline always responds 200 with steps.get-workflow.row even when the workflow ID doesn't exist. step.db_query in mode: single returns found: false and an empty row, so this endpoint will return {} with 200 instead of a 404 (unlike the GET/PUT/DELETE workflow routes above).
Add a conditional step on steps.get-workflow.found and a not-found json_response (404) route, or otherwise fail the pipeline when no row is found.
| mode: single | |
| - name: respond | |
| type: step.json_response | |
| mode: single | |
| - name: not-found | |
| type: step.json_response | |
| condition: "{{ not .steps.get-workflow.found }}" | |
| config: | |
| status: 404 | |
| body: | |
| error: "workflow not found" | |
| - name: respond | |
| type: step.json_response | |
| condition: "{{ .steps.get-workflow.found }}" |
|
@copilot open a new pull request to apply changes based on the comments in this thread |
* 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>
Summary
Replace the last 2 V1 admin CRUD routes (deploy and stop) that still delegated to
admin-v1-mgmt(V1APIHandler) with declarative pipeline definitions usingadmin-db.Routes Decomposed
All 6 routes from Phase B now use pipeline primitives:
/api/v1/admin/organizations/{id}/projects/api/v1/admin/projects/{id}/workflows/api/v1/admin/workflows/api/v1/admin/workflows/{id}/api/v1/admin/workflows/{id}/deploy/api/v1/admin/workflows/{id}/stopPipeline Pattern (deploy/stop)
Each route now uses pipeline steps (
request_parse,set,db_exec,db_query,json_response) instead of Go delegates, consistent with the other decomposed routes.Verification
go build✅go test ./...✅go vet ./...✅golangci-lint run✅Closes #86