Resolve Calculated Policy Evaluation Errors
In this guide, you will identify and resolve a calculated policy evaluation error using the Guardrails console.
A Calculated Policy dynamically determines policy settings by sourcing CMDB data, executing a GraphQL query, and applying a Nunjucks template to generate a resource-specific policy value. Any policy setting can be calculated, making policies more context-aware and adaptable.
However, calculated policies can encounter errors due to misconfigurations or data inconsistencies, leading to controls entering an error state. Ensuring these policies are properly configured and promptly fixed is crucial for maintaining compliance and system stability.
Prerequisites
- Turbot/Admin permissions at the Turbot resource level.
- Familiarity with the Guardrails console.
- Knowledge of the Nunjucks template language.
Step 1: Find the Policy Values in Error
Calculated values that fail template rendering show as error. Open the calculated policy setting and select its Values tab (or filter the Policies Values view by State: Error) to see the affected resources. Each shows a Template render error.

Step 2: View the Error Details
Click a value row to open its Policy Value page. The Value panel is marked ERROR and CALCULATED, and shows the full error message. In this example, Unable to call $["bucket"]["turbot"]["tags"]["nonExistentTag"]["toString"], which is undefined or falsey, which tells you the template is accessing a property that doesn't exist on the resource.

Step 3: Edit the Policy Setting
In the hierarchy, open the effective calculated setting and click Edit. The Update Policy Setting form opens in calculated mode, showing the input query and template. Click Launch calculated policy builder to open the builder.

Step 4: Identify the Error in the Builder
The builder opens with the existing query and template. Pick a Test Resource in Step 1 if one isn't already selected. The Output panel under Step 3 is highlighted in red and shows the render error, confirming which line of the template is failing.

Step 5: Fix the Template
Correct the Nunjucks template in the Step 3 panel. When the fix is valid, the Output panel turns green and Step 4 shows the transformed value passing the policy type schema. Click Update to return to the settings form.

Back on the Update Policy Setting form, review the corrected template and click Update.

Step 6: Verify the Fix
After saving, the policy value re-evaluates. Confirm on the Policy Value page that the value transitions from error to a valid state (for example Check: Enabled), which confirms the calculated policy is now producing the correct output.

Troubleshooting
| Issue | Solution |
|---|---|
| Template references an undefined property | Check the GraphQL query result to verify the data structure. Use conditional checks (for example {%- if $.bucket.turbot.tags.myTag -%}) to handle missing properties. |
| Template produces an invalid value | The output must be one of the valid values for the policy type. Check for typos, since values are case-sensitive. |
| Policy value stays in error after saving | Use the value's Actions menu to re-run it, and check the Activity or logs for process details. |
| Further assistance | Open a Support Ticket |