Skip to content

Conversation

Copy link

Copilot AI commented Nov 20, 2025

The terraform-validate workflow failed silently with generic error messages, forcing contributors to guess what needed fixing or re-run with manual debugging.

Changes

Added workflow_dispatch with debug input

  • Manual trigger with boolean toggle for verbose output
  • Defaults to false to preserve existing behavior

Enhanced error output for all linting steps

Terraform Fmt

  • Always lists files needing formatting
  • Debug mode shows full diff

Terraform Validate

  • Always shows parsed validation errors with severity
  • Debug mode includes complete JSON output
  • Graceful fallback if jq parsing fails

TFLint

  • Always shows formatted issues: [SEVERITY] rule in file:line: message
  • Creates GitHub annotations for inline PR feedback
  • Debug mode includes full JSON output

Updated workflow summary

  • Indicates debug mode status when enabled
  • Points to step logs for error details
  • Prompts to re-run with debug mode when checks fail

Example output

Before:

::error::Terraform format check failed! Run 'terraform fmt -recursive' locally to fix formatting issues.

After (default):

::error::Terraform format check failed! Run 'terraform fmt -recursive' locally to fix formatting issues.

Files that need formatting:
main.tf
variables.tf
outputs.tf

After (debug mode):

Files that need formatting:
main.tf
variables.tf

Formatting differences:
--- old/main.tf
+++ new/main.tf
@@ -15,7 +15,7 @@
-resource "azurerm_resource_group" "main"{
+resource "azurerm_resource_group" "main" {

Technical approach

Error handling pattern captures output before exit:

FMT_OUTPUT=$(terraform fmt -check -recursive -diff 2>&1) || FMT_EXIT=$?
if [ "${FMT_EXIT:-0}" -ne 0 ]; then
  terraform fmt -check -recursive 2>&1 | grep -v "^$"  # Always show files
  [ "${{ github.event.inputs.debug }}" == "true" ] && echo "$FMT_OUTPUT"  # Debug shows diff
  exit 1
fi

All JSON parsing includes fallback: jq ... 2>/dev/null || cat file

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug] Linter Workflow Outputs No Error Details</issue_title>
<issue_description>### Is there an existing issue?

  • I have searched the existing issues

Description

No response

Steps to Reproduce

  1. Run one of the linter or validation workflows in this repo with a change that will force an error to occur.
  2. Observe minimal details in the workflow when an error occurs.

Expected Behavior

When the linter in terraform-validate.yml encounters an error on things like terraform fmt, it should output the details of the linter error rather than a generic error.

It seems like this is happening because we (correctly) do not run any steps with verbose output in the default workflows. Probably the best way to make this happen is to add a 'debug' option to terraform-validate.yml so that affected contributors could use it to re-run the workflow with more verbose output. But anything that makes it easy to get more details when there are workflow errors would suffice.

Anything else?

No response</issue_description>

<agent_instructions>Only change terraform-validate.yml .</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@devorekristen need to change behavior. linter just notifies it failed instead of providing explanation of what linter checks failed. all of our checks are not detailed when they have errors.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add debug option to linter workflow for detailed error output Add debug mode and detailed error output to terraform-validate workflow Nov 20, 2025
Copilot AI requested a review from ianjensenisme November 20, 2025 19:11
Copilot finished work on behalf of ianjensenisme November 20, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Linter Workflow Outputs No Error Details

2 participants