fix: return 404 from a few populators (#2031)

This commit is contained in:
matt
2025-07-21 14:41:36 -04:00
committed by GitHub
parent c26ff03dc0
commit 42cb2d2dcc
2 changed files with 7 additions and 3 deletions

View File

@@ -120,6 +120,10 @@ func (p *Populator) traverseNode(c echo.Context, node *resource) error {
err := p.callGetter(node, node.ParentID, node.ResourceID)
if err != nil {
if httpErr, ok := err.(*echo.HTTPError); ok {
return httpErr
}
return fmt.Errorf("could not populate resource %s: %w", node.ResourceKey, err)
}

View File

@@ -301,7 +301,7 @@ func (t *APIServer) registerSpec(g *echo.Group, spec *openapi3.T) (*populator.Po
}
if scheduled == nil {
return nil, "", fmt.Errorf("scheduled workflow run not found")
return nil, "", echo.NewHTTPError(http.StatusNotFound, "scheduled workflow run not found")
}
return scheduled, sqlchelpers.UUIDToStr(scheduled.TenantId), nil
@@ -315,7 +315,7 @@ func (t *APIServer) registerSpec(g *echo.Group, spec *openapi3.T) (*populator.Po
}
if scheduled == nil {
return nil, "", fmt.Errorf("cron workflow not found")
return nil, "", echo.NewHTTPError(http.StatusNotFound, "cron workflow not found")
}
return scheduled, sqlchelpers.UUIDToStr(scheduled.TenantId), nil
@@ -381,7 +381,7 @@ func (t *APIServer) registerSpec(g *echo.Group, spec *openapi3.T) (*populator.Po
}
if task == nil {
return nil, "", fmt.Errorf("task not found")
return nil, "", echo.NewHTTPError(http.StatusNotFound, "task not found")
}
return task, sqlchelpers.UUIDToStr(task.TenantID), nil