{"record":{"id":"e63d06b4689da441","repo":"argoproj/argo-workflows","slug":"failed-to-evaluate-stop-expression-w","errorCode":null,"errorMessage":"failed to evaluate stop expression: %w","messagePattern":"failed to evaluate stop expression: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"workflow/cron/operator.go","lineNumber":559,"sourceCode":"\t}\n\tprefixedEnv := make(map[string]any)\n\tprefix := variablePrefix + \".\"\n\tsetField := func(name string, value any) {\n\t\t// `name` is the canonical \"cronworkflow.X\". Strip the\n\t\t// \"cronworkflow.\" prefix because we expose the inner map under the\n\t\t// \"cronworkflow\" key for expr-lang member access.\n\t\tprefixedEnv[strings.TrimPrefix(name, prefix)] = value\n\t}\n\tenv := make(map[string]any)\n\tenv[variablePrefix] = prefixedEnv\n\terr := expressionEnv(woc.cronWf, setField)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\tsuspend, err := argoexpr.EvalBool(woc.cronWf.Spec.StopStrategy.Expression, env)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to evaluate stop expression: %w\", err)\n\t}\n\treturn suspend, nil\n}\n\nfunc (woc *cronWfOperationCtx) setAsCompleted() {\n\twoc.cronWf.Status.Phase = v1alpha1.StoppedPhase\n\tif woc.cronWf.Labels == nil {\n\t\twoc.cronWf.Labels = map[string]string{}\n\t}\n\twoc.cronWf.Labels[common.LabelKeyCronWorkflowCompleted] = \"true\"\n}\n\nfunc inferScheduledTime(ctx context.Context) time.Time {\n\t// Infer scheduled runtime by getting current time and zeroing out current seconds and nanoseconds\n\t// This works because the finest possible scheduled runtime is a minute. It is unlikely to ever be used, since this\n\t// function is quickly supplanted by a deterministic function from the cron engine.\n\tnow := time.Now().UTC()\n\tscheduledTime := time.Date(now.Year(), now.Month(), now.Day(), now.Hour(), now.Minute(), 0, 0, now.Location())","sourceCodeStart":541,"sourceCodeEnd":577,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/workflow/cron/operator.go#L541-L577","documentation":"The stop expression configured on a CronWorkflow's spec.stopStrategy could not be evaluated as a boolean by the expr language evaluator (argoexpr.EvalBool). checkStopingCondition builds an environment (e.g. cronWorkflow schedule data) and evaluates the expression; any evaluation failure is wrapped with this message.","triggerScenarios":"spec.stopStrategy.expression is syntactically invalid, references an unknown variable in the environment, compares mismatched types, or does not evaluate to a bool.","commonSituations":"Copy-pasted expressions using the wrong variable names, using an expression from older docs with renamed fields, or non-boolean expressions like arithmetic results.","solutions":["Check the wrapped cause (%w) in the controller log for the expr parse/eval error detail","Ensure the expression is valid expr-lang syntax and evaluates to a bool","Reference only variables provided in the evaluation environment (see docs on CronWorkflow stopStrategy)","Test the expression with expr-lang's REPL or a unit test before deploying"],"exampleFix":"// before\nstopStrategy:\n  expression: scheduledTime  // non-boolean\n// after\nstopStrategy:\n  expression: cronWorkflow.lastScheduledTime.After(now()) == true","handlingStrategy":"validation","validationCode":"// Validate before apply: must parse and return bool\nprogram, err := expr.Compile(cronWf.Spec.StopStrategy.Expression,\n    expr.Env(stopEnv), expr.AsBool())\nif err != nil {\n    return fmt.Errorf(\"stopStrategy.expression invalid: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Compile expressions in CI with expr.AsBool to catch syntax/type errors early","Only reference identifiers documented for stopStrategy environments","Add a canary CronWorkflow when introducing new expressions","Keep a lint step (argo lint + custom expr check) in your GitOps pipeline"],"tags":["expression-evaluation","cronworkflow","config","argo-workflows"],"backgroundTag":"expression-evaluation-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}