From fb56930a2b564924890457643d06d8c2debeeb0a Mon Sep 17 00:00:00 2001 From: Sivaselvan32 Date: Fri, 21 Aug 2026 10:41:03 +0530 Subject: [PATCH] fix(run): add missing tf_policy_checked/tf_policy_override RunStatus values atlas introduced these two run statuses alongside tf-policy (the analogues of the pre-existing policy_checked/policy_override statuses for the Sentinel/OPA flow), but RunStatus never picked them up. A run paused awaiting a tf-policy override decision reports status: "tf_policy_override" on the wire, and client.runs.read()/.list() raised a pydantic validation error instead of returning the run. Found via live testing of the hashicorp.terraform Ansible collection's new tf-policy modules against a real run that reached this status - no mocked unit fixture had exercised it before. Bumps to 1.4.1. --- CHANGELOG.md | 11 +++++++++++ pyproject.toml | 2 +- src/pytfe/models/run.py | 2 ++ tests/units/test_run.py | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53016803..4b6bb74a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,17 @@ # Unreleased # Released +# v1.4.1 + +## Bug Fixes + +* Added the `tf_policy_checked` and `tf_policy_override` values to `RunStatus`. A run + paused awaiting a tf-policy override decision reports `status: "tf_policy_override"` + on the wire; without this fix, `client.runs.read()` (and anything that parses a `Run` + through this status) raised a validation error instead of returning the run. + Discovered via live testing of the `hashicorp.terraform` Ansible collection's + tf-policy modules — no mocked unit fixture had exercised this status before. + # v1.4.0 ## Enhancements diff --git a/pyproject.toml b/pyproject.toml index cee40a3b..6f701e62 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pytfe" -version = "1.4.0" +version = "1.4.1" description = "Official Python SDK for HashiCorp Terraform Cloud / Terraform Enterprise (TFE) API v2" readme = "README.md" license = { text = "MPL-2.0" } diff --git a/src/pytfe/models/run.py b/src/pytfe/models/run.py index 1d0a09a3..86f2921e 100644 --- a/src/pytfe/models/run.py +++ b/src/pytfe/models/run.py @@ -70,6 +70,8 @@ class RunStatus(str, Enum): Run_Pre_Plan_Running = "pre_plan_running" Run_Queuing = "queuing" Run_Queuing_Apply = "queuing_apply" + Run_Tf_Policy_Checked = "tf_policy_checked" + Run_Tf_Policy_Override = "tf_policy_override" class RunIncludeOpt(str, Enum): diff --git a/tests/units/test_run.py b/tests/units/test_run.py index 7a72d2cb..64fde45e 100644 --- a/tests/units/test_run.py +++ b/tests/units/test_run.py @@ -523,3 +523,23 @@ def test_discard_run_success(self, runs_service): assert call_args[0][0] == "POST" assert call_args[0][1] == "/api/v2/runs/run-discard-123/actions/discard" assert call_args[1]["json_body"]["comment"] == "Discarding run" + + +class TestRunStatusTfPolicy: + """Regression test: atlas introduced ``tf_policy_checked`` and + ``tf_policy_override`` run statuses alongside tf-policy (the analogues + of the pre-existing ``policy_checked``/``policy_override`` statuses for + the Sentinel/OPA flow). A run that pauses awaiting a tf-policy override + decision reports ``status: "tf_policy_override"`` on the wire - if the + enum doesn't know that value, parsing the run raises a validation error + instead of returning the status. Caught only by live testing against a + run that actually reached this status; no mocked fixture exercised it. + """ + + def test_tf_policy_override_status_parses(self): + run = Run.model_validate({"id": "run-abc123", "status": "tf_policy_override"}) + assert run.status == RunStatus.Run_Tf_Policy_Override + + def test_tf_policy_checked_status_parses(self): + run = Run.model_validate({"id": "run-abc123", "status": "tf_policy_checked"}) + assert run.status == RunStatus.Run_Tf_Policy_Checked