Skip to content

Commit fb56930

Browse files
committed
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.
1 parent 6fcabf4 commit fb56930

4 files changed

Lines changed: 34 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
# Unreleased
22

33
# Released
4+
# v1.4.1
5+
6+
## Bug Fixes
7+
8+
* Added the `tf_policy_checked` and `tf_policy_override` values to `RunStatus`. A run
9+
paused awaiting a tf-policy override decision reports `status: "tf_policy_override"`
10+
on the wire; without this fix, `client.runs.read()` (and anything that parses a `Run`
11+
through this status) raised a validation error instead of returning the run.
12+
Discovered via live testing of the `hashicorp.terraform` Ansible collection's
13+
tf-policy modules — no mocked unit fixture had exercised this status before.
14+
415
# v1.4.0
516

617
## Enhancements

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "pytfe"
7-
version = "1.4.0"
7+
version = "1.4.1"
88
description = "Official Python SDK for HashiCorp Terraform Cloud / Terraform Enterprise (TFE) API v2"
99
readme = "README.md"
1010
license = { text = "MPL-2.0" }

src/pytfe/models/run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class RunStatus(str, Enum):
7070
Run_Pre_Plan_Running = "pre_plan_running"
7171
Run_Queuing = "queuing"
7272
Run_Queuing_Apply = "queuing_apply"
73+
Run_Tf_Policy_Checked = "tf_policy_checked"
74+
Run_Tf_Policy_Override = "tf_policy_override"
7375

7476

7577
class RunIncludeOpt(str, Enum):

tests/units/test_run.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,3 +523,23 @@ def test_discard_run_success(self, runs_service):
523523
assert call_args[0][0] == "POST"
524524
assert call_args[0][1] == "/api/v2/runs/run-discard-123/actions/discard"
525525
assert call_args[1]["json_body"]["comment"] == "Discarding run"
526+
527+
528+
class TestRunStatusTfPolicy:
529+
"""Regression test: atlas introduced ``tf_policy_checked`` and
530+
``tf_policy_override`` run statuses alongside tf-policy (the analogues
531+
of the pre-existing ``policy_checked``/``policy_override`` statuses for
532+
the Sentinel/OPA flow). A run that pauses awaiting a tf-policy override
533+
decision reports ``status: "tf_policy_override"`` on the wire - if the
534+
enum doesn't know that value, parsing the run raises a validation error
535+
instead of returning the status. Caught only by live testing against a
536+
run that actually reached this status; no mocked fixture exercised it.
537+
"""
538+
539+
def test_tf_policy_override_status_parses(self):
540+
run = Run.model_validate({"id": "run-abc123", "status": "tf_policy_override"})
541+
assert run.status == RunStatus.Run_Tf_Policy_Override
542+
543+
def test_tf_policy_checked_status_parses(self):
544+
run = Run.model_validate({"id": "run-abc123", "status": "tf_policy_checked"})
545+
assert run.status == RunStatus.Run_Tf_Policy_Checked

0 commit comments

Comments
 (0)