How to troubleshoot runs not starting
Last updated: July 14, 2025
This guide will walk you through the process of troubleshooting policies using the policy workbench, with a focus on a common scenario involving a tracked run or a proposed run not starting from a PR.
For more information on the policy workbench and sampling, refer to the Policy Workbench Documentation.
Scenario: Run Not Being Triggered
Let's consider a scenario where a run is not being triggered as expected. We'll use the default push policy as an example and review it in the policy workbench.
1. Create a New Policy:
Navigate to the Policies section from the left-hand menu.
Click the Create policy button.
Provide a name for the policy, such as "Default Push Policy".
Choose Push as the policy type.
Pick the Space which will be assessable to your stack.
Add the Default Push Policy Code:
In the policy editor, paste the default push policy and make sure you include the
samplelinesample := true
Save the Policy:
Click the Save button at the bottom of the policy editor.
2. Attaching the Policy to a Stack
Navigate to Stacks:
Go to the Stacks section from the left-hand menu.
Select the Stack:
Click on the stack to which you want to attach the policy.
Attach the Policy:
Go to the Settings tab of the stack.
Find the Policies section.
Click Attach policy.
Select the "Default Push Policy" from the dropdown.
Click Attach.
3. Repeat the Action to Test the Policy
Open a Pull Request:
Go to your GitHub repository linked to the stack.
Make a change and open a new pull request.
Check Spacelift for the Run:
Navigate back to Spacelift.
Go to the Runs tab of the stack to see if the run was triggered.
4. Reviewing the Policy in the Workbench
Navigate to the Policy Workbench:
Go to the Policies screen in Spacelift and click on the policy you want to review.
Click on the Show simulation panel link on the right-hand side of the screen.
View Sampled Events:
If you have no samples - verify that the
samplerule is set totrue.If the
samplerule istrueand you have no sampled events, then Spacelift did not receive this event. In this case, we recommend reviewing the relevant documentation for your source code provider and check your repository has the correct settings.
Simulate Evaluations:
Select an input to simulate its evaluation. You can edit both the input and the policy body in the simulation panel.
The dropdown will display evaluations, allowing you to see the conditions and results of each rule.
Analyze the Conditions:
Click on simulate and check the
trackedandproposedresults - if a run was not triggered, this should show asfalseIf it shows as
falsethen all conditions within the tracked and proposed blocks were not met.
Understanding the Conditions:
The
trackrule requiresaffectedto be true and the push branch to be the same branch as the Stack's branch.The
proposerule requires eitheraffectedoraffected_prto be true. (In Rego - an overloaded rule acts as an OR)The
affectedrules check if any file in theaffected_fileslist either starts with theproject_rootor matches the project glob pattern.Similarly,
affected_prrules check thepull_request.difflist against the same conditions.
Example Analysis:
Given the following snippets from the sampled data:
"stack": { "additional_project_globs": [], "branch": "main", "project_root": "wrongprojectroot","push": { "affected_files": ["projectroot/main.tf"], "branch": "other","pull_request": { "diff": ["projectroot/main.tf"],Both
affectedandaffected_prwill be false because the file in both lists starts does not start with theproject_root.If you change
"project_root"in the stack section toprojectrootbothaffectedandaffected_prwill be true, makingproposetrue, and a proposed run would start.Since the stacks branch is
mainand the push events branch isothertheinput.push.branch == input.stack.branchconditionis not truemeaningtrackrule is not true as not all conditions have been met and tracked run would not start.