Skip to content

[CI Failure Doctor] Check Go formatting step failed - code not properly formatted #9913

@github-actions

Description

@github-actions

🏥 CI Failure Investigation - Run #20984232736

Summary

The CI workflow failed because Go code was not properly formatted before committing. The "Check Go formatting" step in the lint-go job detected unformatted code.

Failure Details

Root Cause Analysis

The commit modified workflow files (.github/workflows/metrics-collector.lock.yml and .github/workflows/metrics-collector.md) but Go code in the repository was not properly formatted according to go fmt standards before the commit was pushed.

The CI workflow includes a formatting check that runs:

unformatted=$(go fmt ./...)
if [ -n "$unformatted" ]; then
  echo "❌ Code is not formatted. Run 'make fmt' to fix."
  exit 1
fi

This check detected that running go fmt ./... would modify files, indicating they were not properly formatted.

Files Changed in Failing Commit

  • .github/workflows/metrics-collector.lock.yml (+7/-10 lines)
  • .github/workflows/metrics-collector.md (+0/-1 lines)

Failed Jobs and Errors

lint-go (Job ID: 60315087487)

  • Failed Step: Check Go formatting (Step 5)
  • Error: go fmt detected unformatted Go code
  • Root Cause: Code was committed without running make fmt or go fmt ./... first

All subsequent steps were skipped:

  • Install golangci-lint (skipped)
  • Run golangci-lint (skipped)
  • Lint error messages (skipped)

Recommended Actions

Immediate Fix

  1. Run formatting: make fmt
  2. Recompile workflows: make recompile
  3. Commit the formatting changes
  4. Push to main branch

For Future Commits

ALWAYS run before committing:

make agent-finish  # Runs build, test, recompile, fmt, lint (~10-15s)

Or at minimum:

make fmt           # Format Go code
make recompile     # Recompile workflow lock files (if workflows changed)

Prevention Strategies

Current Documentation Issues

The repository's AGENTS.md file states:

ALWAYS RUN AGENT-FINISH BEFORE COMMITTING:

make agent-finish  # Runs build, test, recompile, fmt, lint

However, this requirement was not followed in PR #9903, suggesting:

  1. The AI agent (Copilot) did not follow the documented workflow
  2. Pre-commit checks may not be enforced
  3. The requirement needs to be more prominent in the workflow

Recommended Improvements

  1. Add pre-commit git hooks to automatically run make fmt
  2. Update GitHub Actions to run formatting checks on PRs before merge
  3. Enhance AI agent instructions with stricter formatting requirements
  4. Add automated reminders in PR templates about running make agent-finish

AI Team Self-Improvement

Additional Prompting Instructions for AI Coding Agents

BEFORE EVERY COMMIT, you MUST:

  1. Run formatting: make fmt (formats Go code using go fmt ./...)
  2. Run recompile: make recompile (recompiles all workflow lock files)
  3. Run complete validation: make agent-finish (runs build, test, recompile, fmt, lint)

These are NOT optional - they are MANDATORY steps.

Why This Matters

The CI workflow has a "Check Go formatting" step that runs go fmt ./... and fails the build if ANY files would be changed. This means:

  • ❌ If you skip make fmt, your PR will fail CI
  • ❌ If you modify workflow files without make recompile, your PR will fail CI
  • ✅ The only way to prevent CI failures is to run these commands BEFORE committing

Failure Pattern Detection

If you see CI failures with:

  • Failed job: "lint-go"
  • Failed step: "Check Go formatting"
  • Error message: "Code is not formatted. Run 'make fmt' to fix."

This means someone committed code without running formatting. The fix is:

make fmt
git add .
git commit --amend --no-edit
git push --force-with-lease

Commit Checklist for AI Agents

Before every commit:

  • Run make fmt - Format all Go code
  • Run make recompile - Recompile workflow lock files (if workflow files changed)
  • Run make lint - Check for linting errors
  • Run make test-unit - Run unit tests
  • Run make agent-finish - Complete validation (recommended)

If you skip these steps, your commit WILL fail CI and waste time.

Historical Context

This is a code quality enforcement failure, not a recurring pattern. The repository has clear documentation about running make agent-finish before commits, but this requirement was not followed in PR #9903.

Pattern Signature: GO_FORMAT_CHECK_FAILED
Severity: Medium
Is Flaky: No
Is Recurring: No
Fix Urgency: Medium

Investigation Notes

  • Category: Code Quality - Formatting
  • Type: Go Code Formatting Check Failed
  • Impact: CI failure blocks the main branch until formatting is fixed
  • Time to Fix: ~5 minutes (run make fmt, commit, push)
  • Preventable: Yes - following documented pre-commit workflow prevents this

This failure is straightforward and easily preventable by following the repository's documented workflow. The issue highlights the need for better enforcement of pre-commit formatting checks, either through git hooks or automated reminders.

AI generated by CI Failure Doctor

To add this workflow in your repository, run gh aw add githubnext/agentics/workflows/ci-doctor.md@ea350161ad5dcc9624cf510f134c6a9e39a6f94d. See usage guide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions