Skip to content

Fix network.firewall.log-level YAML indentation in smoke-copilot workflows#6382

Merged
pelikhan merged 5 commits intomainfrom
copilot/fix-gh-aw-action-step
Dec 14, 2025
Merged

Fix network.firewall.log-level YAML indentation in smoke-copilot workflows#6382
pelikhan merged 5 commits intomainfrom
copilot/fix-gh-aw-action-step

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 14, 2025

Fix Network Firewall Codemod to Handle Nested Properties

  • Fix YAML syntax errors in smoke-copilot workflows
  • Fix the codemod that caused the issue
  • Add test for nested firewall properties
  • Handle comments and empty lines within firewall block
  • Refactor to reduce code duplication
  • Verify all tests pass

Root Cause

The network.firewall to sandbox.agent codemod was only removing the firewall: line but not its nested properties (like log-level: debug). This left orphaned properties at the wrong indentation level, causing YAML parsing errors.

Solution

Updated the codemod to:

  1. Track when inside a firewall: block
  2. Remove all nested properties (lines with greater indentation)
  3. Remove comments and empty lines within the firewall block
  4. Properly exit the block when encountering a line at same or less indentation
  5. Extract indentation calculation to avoid duplication

Changes

  1. Fixed codemod logic (pkg/cli/fix_codemods.go):

    • Added inFirewallBlock and firewallIndent tracking
    • Skip lines with greater indentation than firewall: line
    • Handle empty lines (remove from firewall block)
    • Handle comments based on indentation (remove if nested, keep if not)
    • Extracted indentation calculation to reduce duplication
    • Log removal of nested properties for debugging
  2. Added comprehensive tests (pkg/cli/fix_command_test.go):

    • TestFixCommand_NetworkFirewallMigrationWithNestedProperties - tests nested properties
    • TestFixCommand_NetworkFirewallMigrationWithCommentsAndEmptyLines - tests comment/empty line handling
    • Verifies that all nested content is removed
    • Ensures the result compiles without YAML syntax errors

Validation

  • ✅ All existing tests pass
  • ✅ New tests pass
  • ✅ smoke-copilot workflows compile successfully
  • ✅ Codemod produces valid YAML that passes compilation
  • ✅ Comments and empty lines within firewall block are properly removed
  • ✅ Code review suggestions addressed
Original prompt

Fix https://github.com/githubnext/gh-aw/actions/runs/20200002978/job/57989663008#step:13:1

Custom agent used: debug-agentic-workflow
Debug and refine agentic workflows using gh-aw CLI tools - analyze logs, audit runs, and improve workflow performance


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Dec 14, 2025
…er firewall

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix action step in gh-aw workflow Fix network.firewall.log-level YAML indentation in smoke-copilot workflows Dec 14, 2025
Copilot AI requested a review from pelikhan December 14, 2025 01:50
Copy link
Copy Markdown
Collaborator

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this problem was created by the fix command that remove firewall: true. codemod fixes must pass compilation.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 14, 2025

@copilot this problem was created by the fix command that remove firewall: true. codemod fixes must pass compilation.

Fixed in commit d6a8edc. The codemod now properly removes nested firewall properties (like log-level: and version:) when migrating network.firewall to sandbox.agent. Added test coverage to ensure the codemod produces valid YAML that compiles successfully.

@pelikhan pelikhan marked this pull request as ready for review December 14, 2025 02:07
Copilot AI and others added 2 commits December 14, 2025 02:09
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan merged commit 936c94d into main Dec 14, 2025
4 checks passed
@pelikhan pelikhan deleted the copilot/fix-gh-aw-action-step branch December 14, 2025 02:13
Copilot AI requested a review from pelikhan December 14, 2025 02:13
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.

2 participants