fixing-tgc-resource-or-test-failures
When to Use This Skill
- When you need to triage and fix a resource conversion or integration test failure in TGC.
How to Use It
1. Initial Error Reporting
If a failure is detected or provided, you MUST report it using the following template before proceeding.
Error Report Template:
- Failed Command:
[The command that failed] - Detailed Logs:
[Paste the full, relevant error logs here] - Mandatory Skill Read:
[Yes/No](Confirm you have readtgc-fix-handwritten-resources-tests-skillortgc-fix-integration-tests-skill) - Analysis:
[Analyze the cause of the failure] - Proposed Solution:
[Outline the solution and ask for user approval before applying it]
2. Triage & Identification (The Data Loss Check)
You MUST perform a strict Triage & Identification process before proposing or applying any changes. Do NOT use is_missing_in_cai: true as a shortcut to pass tests if the CAI asset actually supports the field.
[NEW] Automated Diagnostics Tool (diagnose_test_failure.py)
To automate this triage, run the integration test with WRITE_FILES=1 enabled:
export WRITE_FILES=1
TF_CLI_CONFIG_FILE="${PWD}/tf-dev-override.tfrc" GO111MODULE=on go test -v ./test/services/<service> -run="<TestName>"
The Go test assertion runner will automatically execute ./test/diagnose_test_failure.py on failure, producing a side-by-side report comparing original CAI assets, HCL exports, and roundtrip configurations. Review this report in the standard test logs.
Step A: Verify CAI Asset Support
Inspect the raw CAI asset file (Test.json or Test_export.json) generated during the failed integration test run (or the automated diagnostics report).
- Rule: If the missing property (e.g.,
"gpuDirectStrategy": "RDMA") is present in the CAI asset, it is NOT missing in CAI. - Constraint: Using
is_missing_in_cai: trueis strictly forbidden. You MUST implement full schema mapping, expander, and flattener logic. - Condition: Only use
is_missing_in_cai: trueif you have verified that the field is permanently omitted from CAI schemas and CAI asset payloads across all tests for this resource.
Step B: Identify Resource Type (Handwritten vs. Generated)
Determine whether the failing resource is handwritten or generated by checking these conditions:
- It is Handwritten if:
- There are custom code files ending in
_cai2hcl.goand_tfplan2cai.gofor the resource inmmv1/third_party/tgc_next/(even if a YAML file exists inproducts/).
- There are custom code files ending in
- It is Generated if:
- A YAML file exists in
products/AND does NOT containexclude_resource: true, AND - There are no custom code files ending in
_cai2hcl.goor_tfplan2cai.goinmmv1/third_party/tgc_next/for this resource.
- A YAML file exists in
Step C: Select Troubleshooting Skill
Based on the resource type, read the corresponding skill before designing a fix:
- Handwritten Resources: Refer to
tgc-fix-handwritten-resources-tests-skill. - Generated Resources: Refer to
tgc-fix-integration-tests-skill.
3. Fix & Implementation Playbook
- Replicate Standard Provider Patterns:
- Locate how the standard provider template (e.g.,
node_config.go.tmpl) maps the field. - Replicate that exact Go/YAML logic directly into the resource's mappings to ensure 100% parity.
- Locate how the standard provider template (e.g.,
- DO NOT modify templates in
mmv1/templates/terraformor shared helper files/templates inmmv1/third_party/terraform. You may modify templates inmmv1/templates/tgc_next. - DO NOT modify legacy TGC code in
mmv1/third_party/cai2hclormmv1/third_party/tgc. All changes must be made to TGC Next code inmmv1/third_party/tgc_next. - DO NOT add new fields to
mmv1/api/resource/custom_code.gounless guided by the user. - DO NOT modify
mmv1/api/resource.goto hardcode or manually append ignored fields for tests. Use resource YAML property renaming withapi_nameinstead to align with the actual Terraform schema. - DO NOT remove existing custom_code.
4. Verification
- Self-check that all failures are reported.
- Proceed to Phase 4 (Generate Code), Phase 5 (Unit Testing), Phase 6 (Integration Testing) after applying fixes.