Add missing RunSource enum values for runs.list_for_organization#121
Closed
KshitijaChoudhari wants to merge 1 commit intonext-0.1.3from
Closed
Add missing RunSource enum values for runs.list_for_organization#121KshitijaChoudhari wants to merge 1 commit intonext-0.1.3from
KshitijaChoudhari wants to merge 1 commit intonext-0.1.3from
Conversation
- Add terraform, tfe-run-trigger, and tfe-infrastructure-lifecycle sources - Add comprehensive unit tests for all RunSource enum values - Update example file to demonstrate all run source types - Fix bug in example file list indexing - Apply proper code formatting
iam404
reviewed
Apr 1, 2026
| Run_Source_Terraform = "terraform" | ||
| Run_Source_Run_Trigger = "tfe-run-trigger" | ||
| Run_Source_Infra_Lifecycle = "tfe-infrastructure-lifecycle" | ||
|
|
Member
There was a problem hiding this comment.
iam404
reviewed
Apr 1, 2026
| # Demonstrate RunSource enum values | ||
| _print_header("Run Source Types Demonstration") | ||
|
|
||
| from pytfe.models.run import RunSource |
Member
There was a problem hiding this comment.
Not getting this change ? We are printing that everything is working without directly using it ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds missing RunSource enum values to support all run sources returned by the Terraform Cloud API. The runs.list_for_organization method was failing to retrieve runs with certain source types due to incomplete enum definitions.
Motivation and Context
The runs.list_for_organization method was failing when encountering runs with source values like "terraform", "tfe-run-trigger", and "tfe-infrastructure-lifecycle" because these weren't defined in the RunSource enum. This caused Pydantic validation errors when the API returned runs with these source types, preventing users from listing all runs in their organization.
Type of Change
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Changes Made
Change 1: Enhanced RunSource enum with missing values
Added Run_Source_Terraform = "terraform" for Terraform CLI runs
Added Run_Source_Run_Trigger = "tfe-run-trigger" for run trigger initiated runs
Added [Run_Source_Infra_Lifecycle = "tfe-infrastructure-lifecycle" for infrastructure lifecycle runs
This ensures complete coverage of all run sources returned by the Terraform Cloud API
Change 2: Added comprehensive unit tests
Created test_run_source_enum_values()
Tests all 7 RunSource enum values to ensure proper validation
Validates that Run model accepts all source types without errors
Change 3: Updated example file with demonstrations
Added RunSource import to run.py
Added "Run Source Types Demonstration" section showing all source types with descriptions
Fixed bug in run actions demo where run_list.items[0] should be run_list[0]
Implementation Details -
Architecture Changes
No architectural changes. This is an enhancement to the existing RunSource enum to support additional API values.
Key Files Changed
run.py : Added 3 new RunSource enum values for complete API coverage
test_run.py = Added comprehensive test coverage for all RunSource enum values
run.py = Updated imports, added demonstration section, and fixed list indexing bug
Testing plan
Unit Tests: All 13 run unit tests pass (including new test for enum values)
Code Quality: Formatting (Ruff), linting, and type checking all pass
Validation: Confirmed that Run model now accepts all 7 run source types without validation errors
Screenshots/Recordings
N/A - This is a backend/model enhancement with no UI changes.
External links
-->
Output from tests
Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.
Integration Tests: All 445 unit tests across the codebase pass
Unit Tests: All 13 run unit tests pass (including new test for enum values)
Breaking Changes
No breaking changes. This is a backward-compatible enhancement that adds support for previously unsupported run source types. Existing code will continue to work as before, but now runs.list_for_organization will successfully retrieve all runs regardless of their source type.
Rollback Plan
No changes to security controls. This PR only adds missing enum values to support additional run source types returned by the Terraform Cloud API. There are no modifications to:
Access controls
Authentication/authorization logic
Encryption mechanisms
Logging functionality
Input validation (beyond expanding the allowed enum values)
Network security
Data handling
PCI review checklist
I have documented a clear reason for, and description of, the change I am making.
If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
If applicable, I've documented the impact of any changes to security controls.
Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.
If you have any questions, please contact your direct supervisor, GRC (#team-grc), or the PCI working group (#proj-pci-reboot). You can also find more information at PCI Compliance.