refactor(deployments): consolidate version reads, status mapping, and v1 auth prologue#5013
Conversation
…owVersions The UI deployments list route and the mothership get_deployment_log handler each had their own inline version query; both now consume the shared persistence helper, so every deployment surface (UI, v1, admin, tools, mothership) reads versions through one code path.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryLow Risk Overview Version reads now go through HTTP status mapping for failed deploy/promote/activate flows uses v1 deploy, undeploy, and rollback share Tests were updated to mock the persistence helpers rather than Reviewed by Cursor Bugbot for commit 2e6570e. Configure here. |
Greptile SummaryThis PR completes the deployment-surface refactoring started in #5009 by centralising four previously copy-pasted code patterns into shared helpers.
Confidence Score: 5/5Safe to merge — purely extracts duplicate code into shared helpers with no observable behavior change on any route surface. All six error-status ternaries are replaced by an equivalent function; the new No files require special attention; the single minor note is in Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
subgraph Routes ["Deployment Route Surfaces"]
R1["v1 /deploy POST+DELETE"]
R2["v1 /rollback POST"]
R3["tools /deploy POST"]
R4["tools /promote POST"]
R5["workflows /deploy POST"]
R6["workflows /deployments/version PATCH"]
end
subgraph Helpers ["New Shared Helpers"]
P1["resolveV1DeploymentWorkflow\n(active record + admin check + 404 mask)"]
P2["statusForOrchestrationError\n(validation→400, not_found→404, else→500)"]
P3["getWorkflowDeploymentVersion\n(single version fetch)"]
P4["listWorkflowVersions\n(version list + Admin fallback)"]
end
R1 --> P1
R2 --> P1
R1 --> P2
R2 --> P2
R3 --> P2
R4 --> P2
R5 --> P2
R6 --> P2
subgraph VersionRoutes ["Version Read Surfaces"]
V1["tools /version GET"]
V2["workflows /deployments/:version GET"]
V3["workflows /deployments GET"]
V4["copilot executeGetDeploymentLog"]
end
V1 --> P3
V2 --> P3
V3 --> P4
V4 --> P4
Reviews (2): Last reviewed commit: "refactor(deployments): shared status map..." | Re-trigger Greptile |
…d v1 workflow resolver - statusForOrchestrationError maps orchestration error codes to HTTP statuses in one place (was an identical ternary in six routes: UI deploy/activate, v1 deploy/rollback, tool deploy/promote) - getWorkflowDeploymentVersion consolidates the single-version fetch used by the UI version GET and the deployments tool version route - resolveV1DeploymentWorkflow extracts the v1 mutation prologue (active-record load, admin permission check, 404 masking) shared by deploy, undeploy, and rollback
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 2e6570e. Configure here.
Summary
get_deployment_lognow consume the sharedlistWorkflowVersionshelper (same shapes, 'Admin' fallback applied in one place)getWorkflowDeploymentVersionhelper backs both the UI version GET and the deployments tool version routestatusForOrchestrationErrorreplaces the identical validation/not_found/else ternary that was copy-pasted in six routesresolveV1DeploymentWorkflowextracts the shared active-record load + admin check + 404 masking used by v1 deploy, undeploy, and rollbackType of Change
Testing
146 tests across the affected suites pass; typecheck and
check:api-validation:strictcleanChecklist