Skip to content

Commit 1c08927

Browse files
fix: propagate DB errors in cancellation checks, remove unimplemented token_budget
- engine.go: don't silently ignore DB errors in cancellation status checks; distinguish sql.ErrNoRows from other errors and return them instead of silently proceeding with unknown cancellation state - workflow_connector.go: remove token_budget from docstring (not implemented) - connectors.md: remove undocumented token_budget param row; add 'cel' language specifier to CEL path code fence Co-authored-by: Michael McNees <michaelmcnees@users.noreply.github.com>
1 parent 165acd5 commit 1c08927

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

packages/engine/internal/engine/engine.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,16 @@ func (e *Engine) resumeExecution(ctx context.Context, execID string, workflowNam
241241
for _, step := range wf.Steps {
242242
// Check if execution was cancelled externally (e.g., mantle cancel).
243243
var currentStatus string
244-
if err := e.DB.QueryRowContext(ctx, "SELECT status FROM workflow_executions WHERE id = $1 AND team_id = $2", execID, sc.TeamID).Scan(&currentStatus); err == nil {
245-
if currentStatus == "cancelled" {
246-
result.Status = "cancelled"
247-
result.Error = "execution cancelled"
248-
return result, nil
244+
if err := e.DB.QueryRowContext(ctx, "SELECT status FROM workflow_executions WHERE id = $1 AND team_id = $2", execID, sc.TeamID).Scan(&currentStatus); err != nil {
245+
if errors.Is(err, sql.ErrNoRows) {
246+
return nil, fmt.Errorf("execution %s not found", execID)
249247
}
248+
return nil, fmt.Errorf("checking cancellation status for %s: %w", execID, err)
249+
}
250+
if currentStatus == "cancelled" {
251+
result.Status = "cancelled"
252+
result.Error = "execution cancelled"
253+
return result, nil
250254
}
251255

252256
// Skip already-completed steps (checkpoint recovery).
@@ -624,7 +628,13 @@ func (e *Engine) executeStepLogic(ctx context.Context, execID string, step workf
624628
for attempt := 1; attempt <= maxAttempts; attempt++ {
625629
// Check if the execution has been cancelled before each retry attempt.
626630
var execStatus string
627-
if err := e.DB.QueryRowContext(ctx, "SELECT status FROM workflow_executions WHERE id = $1 AND team_id = $2", execID, sc.TeamID).Scan(&execStatus); err == nil && execStatus == "cancelled" {
631+
if err := e.DB.QueryRowContext(ctx, "SELECT status FROM workflow_executions WHERE id = $1 AND team_id = $2", execID, sc.TeamID).Scan(&execStatus); err != nil {
632+
if errors.Is(err, sql.ErrNoRows) {
633+
return nil, fmt.Errorf("execution %s not found", execID)
634+
}
635+
return nil, fmt.Errorf("checking cancellation status for %s: %w", execID, err)
636+
}
637+
if execStatus == "cancelled" {
628638
return nil, fmt.Errorf("execution cancelled")
629639
}
630640

packages/engine/internal/engine/workflow_connector.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ type WorkflowConnector struct {
2525
// - workflow (string, required): name of the child workflow
2626
// - version (int, optional): version to run; 0 or omitted = latest
2727
// - inputs (map[string]any, optional): input parameters for the child
28-
// - token_budget (int64, optional): token budget override for the child
2928
func (wc *WorkflowConnector) Execute(ctx context.Context, params map[string]any) (map[string]any, error) {
3029
// Extract required workflow name.
3130
workflowName, ok := params["workflow"].(string)

packages/site/src/content/docs/workflow-reference/connectors.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,6 @@ Invokes another workflow as a child execution. The child workflow runs synchrono
606606
| `workflow` | string | Yes | Name of the child workflow to execute. |
607607
| `version` | integer | No | Specific version to run. Omit to use the latest applied version. |
608608
| `inputs` | map | No | Input parameters to pass to the child workflow. |
609-
| `token_budget` | integer | No | Token budget override for the child execution. |
610609

611610
**Output:**
612611

@@ -620,7 +619,7 @@ Invokes another workflow as a child execution. The child workflow runs synchrono
620619

621620
Child step outputs are nested under the parent step's output:
622621

623-
```
622+
```cel
624623
steps['my-step'].output.steps['child-step'].output.field
625624
```
626625

0 commit comments

Comments
 (0)