Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 15, 2026

All 122 workflows had SC2155 shellcheck errors: declaring and assigning variables with command substitution in one line masks command failures and prevents proper error detection.

Changes

  • Modified pkg/workflow/mcp_servers.go to generate shell code that separates variable declaration from assignment
    • Safe Inputs API key generation (line 389-390)
    • MCP Gateway API key generation and export (lines 503-505)

Before

# Masks openssl failures - $? is always 0
API_KEY=$(openssl rand -base64 45 | tr -d '/+=')
export MCP_GATEWAY_API_KEY="$(openssl rand -base64 45 | tr -d '/+=')"

After

# Preserves openssl exit code for error handling
API_KEY=""
API_KEY=$(openssl rand -base64 45 | tr -d '/+=')

MCP_GATEWAY_API_KEY=""
MCP_GATEWAY_API_KEY=$(openssl rand -base64 45 | tr -d '/+=')
export MCP_GATEWAY_API_KEY

Impact

  • Eliminated all 122 SC2155 errors (100% of occurrences)
  • Single source fix automatically propagated to all affected workflows via recompilation
  • Command failures now properly detectable in workflow execution
Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Fix critical shellcheck issues across high-priority workflows</issue_title>
<issue_description>## Objective

Address critical shellcheck errors (SC2155 and other high-impact issues) in the highest-traffic workflows to improve shell script reliability and prevent bugs.

Context

Tool: actionlint + shellcheck
Count: 197 errors across 118 workflows (95.2%)
Most Common: SC2155 - Declare and assign separately to avoid masking return values
Reference: https://www.shellcheck.net/wiki/SC2155

Shellcheck findings indicate shell scripting patterns that can lead to subtle bugs, masked errors, and unexpected behavior. SC2155 is particularly problematic because it can hide command failures.

Problem Example

Bad (SC2155):

local result=$(some_command)  # If some_command fails, $? is 0 (success)

Good:

local result
result=$(some_command)  # If some_command fails, $? reflects the failure

Approach

  1. Identify the top 15-20 highest-traffic workflows with SC2155 errors
  2. For each workflow, review shell script blocks in the compiled .lock.yml files
  3. Separate variable declaration from assignment for local variables
  4. Add proper error checking after command execution
  5. Test that the fix doesn't break workflow functionality
  6. Run make recompile after modifying the source .md files

Priority workflows (likely high-traffic based on naming):

  • CI/CD workflows (ci-doctor, ci-coach)
  • Security workflows (security-compliance, security-fix-pr)
  • Core automation (audit-workflows, compiler-checker)

Files to Modify

Target 15-20 workflows with the highest impact:

  • .github/workflows/ci-doctor.md
  • .github/workflows/ci-coach.md
  • .github/workflows/security-compliance.md
  • .github/workflows/audit-workflows.md
  • Plus 10-15 more from the affected list

Example Fix

Before (in workflow .md file):

- name: Process result
  run: |
    local output=$(git status)
    echo "$output"

After:

- name: Process result
  run: |
    local output
    output=$(git status) || { echo "git status failed"; exit 1; }
    echo "$output"

Acceptance Criteria

  • Top 15-20 workflows have SC2155 fixed
  • Proper error handling added for command execution
  • All modified workflows compile successfully
  • Shellcheck error count reduced by at least 50 issues
  • No functionality broken by the changes
  • make test passes

Testing

# After each fix, compile and check
make build
./gh-aw compile .github/workflows/<workflow-name>.md

# Run actionlint to verify shellcheck issues reduced
make recompile
actionlint .github/workflows/*.lock.yml 2>&1 | grep "SC2155" | wc -l

# Run full test suite
make test

Notes

AI generated by Plan Command for discussion #9966

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


✨ 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 and others added 3 commits January 15, 2026 06:04
Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
- Separated variable declaration from assignment for API_KEY and MCP_GATEWAY_API_KEY
- Fixed in pkg/workflow/mcp_servers.go to generate proper shell code
- Eliminated all 122 SC2155 errors across all workflows

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
- Fixed 122 SC2155 shellcheck errors across all workflows
- Pre-existing test failure in pkg/campaign unrelated to this fix
- All shellcheck SC2155 errors now resolved

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix critical shellcheck issues in high-priority workflows Fix SC2155 shellcheck errors in generated workflow scripts Jan 15, 2026
Copilot AI requested a review from mnkiefer January 15, 2026 06:23
@pelikhan pelikhan added the smoke label Jan 15, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟

@github-actions
Copy link
Contributor

github-actions bot commented Jan 15, 2026

🎉 Yo ho ho! Changeset Generator found the treasure and completed successfully! ⚓💰

@github-actions
Copy link
Contributor

Smoke Test Results - Run #21022051669

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Retrieved merged PRs successfully
  • ❌ Serena Go: Command not found (expected in Copilot workflow)
  • ✅ Playwright: Navigated to GitHub, page title verified
  • ✅ File Writing: Test file created at /tmp/gh-aw/agent/smoke-test-copilot-21022051669.txt
  • ✅ Bash Tool: File verified with cat command

Status: PASS (4/5 tests passed, go command unavailability is expected)

cc: @pelikhan

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

Smoke Test Results (Claude)

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Fetched PR list
  • ❌ Serena Go: Tool not available for command execution
  • ✅ Playwright: Navigated to GitHub (title verified)
  • ✅ Tavily Search: 5 results returned
  • ✅ File Writing: Test file created
  • ✅ Bash Tool: File verified

Overall: PARTIAL PASS (5/6 tests passed)

AI generated by Smoke Claude

@pelikhan pelikhan marked this pull request as ready for review January 15, 2026 06:51
@pelikhan pelikhan merged commit 92d6103 into main Jan 15, 2026
36 checks passed
@pelikhan pelikhan deleted the copilot/fix-shellcheck-issues branch January 15, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Fix critical shellcheck issues across high-priority workflows

3 participants