Skip to content

Fix undefined property error for comment outputs in workflows without reactions#3831

Merged
pelikhan merged 6 commits into
mainfrom
copilot/fix-undefined-property-error
Nov 13, 2025
Merged

Fix undefined property error for comment outputs in workflows without reactions#3831
pelikhan merged 6 commits into
mainfrom
copilot/fix-undefined-property-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 13, 2025

Fix undefined property error for comment outputs in workflows without reactions

Problem Analysis

The workflow referenced needs.activation.outputs.comment_id and needs.activation.outputs.comment_repo in the create_pull_request job, but these outputs were not defined in the activation job.

Root Cause:

  • The compiler in pkg/workflow/create_pull_request.go (lines 91-92) unconditionally added environment variables that referenced these outputs
  • These outputs are only created when reaction: is configured in the workflow frontmatter (see pkg/workflow/compiler_jobs.go lines 560-563)
  • The developer-docs-consolidator workflow doesn't have a reaction configured, so the activation job doesn't define these outputs

Implementation Complete ✅

  • Analyze the issue and understand the root cause
  • Modify pkg/workflow/create_pull_request.go to conditionally add comment environment variables only when needed
  • Modify pkg/workflow/push_to_pull_request_branch.go to apply the same fix
  • Update test to include reaction configuration
  • Add comprehensive tests for all scenarios
  • Run actionlint to verify the error is resolved
  • Recompile the developer-docs-consolidator workflow
  • Verify no other workflows are affected
  • Run all unit tests successfully
  • Merge main branch (commit 53b85c8)
  • Lint code (all checks pass)
  • Fix tests (all tests pass)

Changes Made

  1. pkg/workflow/create_pull_request.go - Added conditional logic to only include GH_AW_COMMENT_ID and GH_AW_COMMENT_REPO env vars when data.AIReaction != "" && data.AIReaction != "none"
  2. pkg/workflow/push_to_pull_request_branch.go - Applied the same fix for consistency
  3. pkg/workflow/push_to_pull_request_branch_test.go - Updated test to include reaction: rocket in the on: section
  4. pkg/workflow/comment_env_vars_conditional_test.go - Added comprehensive tests covering all scenarios
  5. Merged main branch - Successfully merged latest changes from main

Verification Results

  • ✅ actionlint passes on developer-docs-consolidator.lock.yml (no errors)
  • ✅ actionlint passes on all other workflows (no comment-related errors)
  • ✅ All unit tests pass after merge (10+ new test cases added)
  • ✅ Lint checks pass
  • ✅ Build succeeds
  • ✅ Workflows with reactions still have comment env vars correctly generated
  • ✅ Workflows without reactions no longer have undefined property references

Recent Merge

Merged main branch (commits 09b416e, 870057e, 59bea31) which includes:

  • Fuzz testing for expression parser security
  • Documentation improvements for PackageExtractor
  • Refactored safe output functions
Original prompt

This section details on the original issue you should resolve

<issue_title>[task] Fix expression_undefined_property error in developer-docs-consolidator workflow</issue_title>
<issue_description>## Objective
Remove undefined activation output references from the developer-docs-consolidator workflow to fix the critical actionlint error.

Context

The workflow references needs.activation.outputs.comment_id and needs.activation.outputs.comment_repo but the activation job is not in the dependency graph. This causes a runtime error when the workflow tries to access these undefined properties. This is part of the static analysis findings from discussion #3824.

Files to Modify

  • .github/workflows/developer-docs-consolidator.md
  • .github/workflows/developer-docs-consolidator.lock.yml (recompiled)

Approach

  1. Open .github/workflows/developer-docs-consolidator.md
  2. Locate the env: section in the frontmatter
  3. Remove the following two lines:
    • GH_AW_COMMENT_ID: ${{ needs.activation.outputs.comment_id }}
    • GH_AW_COMMENT_REPO: ${{ needs.activation.outputs.comment_repo }}
  4. Save the file
  5. Recompile the workflow: make recompile or gh aw compile developer-docs-consolidator
  6. Verify the actionlint error is resolved

Acceptance Criteria

  • GH_AW_COMMENT_ID and GH_AW_COMMENT_REPO environment variables removed from workflow frontmatter
  • Workflow recompiled successfully without actionlint errors
  • Lock file updated with the changes
  • No other functionality affected
    Related to 🔍 Static Analysis Report - 2025-11-13 #3824

AI generated by Plan Command for discussion #3824</issue_description>

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

@pelikhan Update compiler to add dependency when safe output is using comment id

✨ 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 November 13, 2025 10:43
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…nt env vars

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix expression_undefined_property error in developer-docs-consolidator workflow Fix undefined property error for comment outputs in workflows without reactions Nov 13, 2025
Copilot AI requested a review from pelikhan November 13, 2025 11:00
@pelikhan pelikhan marked this pull request as ready for review November 13, 2025 11:04
Copilot AI review requested due to automatic review settings November 13, 2025 11:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a critical bug where the compiler unconditionally referenced needs.activation.outputs.comment_id and needs.activation.outputs.comment_repo in safe output jobs, even though these outputs are only created when a reaction: is configured in the workflow frontmatter. The fix adds conditional logic to only include these environment variables when data.AIReaction != "" && data.AIReaction != "none", matching the condition under which the activation job creates these outputs.

Key changes:

  • Added conditional logic in create_pull_request.go and push_to_pull_request_branch.go to only reference comment outputs when reactions are configured
  • Comprehensive test suite covering workflows with reactions, without reactions, and with reaction: none
  • Updated existing test to include reaction: configuration

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/workflow/create_pull_request.go Added conditional check before adding GH_AW_COMMENT_ID and GH_AW_COMMENT_REPO env vars
pkg/workflow/push_to_pull_request_branch.go Added conditional check before adding GH_AW_COMMENT_ID and GH_AW_COMMENT_REPO env vars
pkg/workflow/comment_env_vars_conditional_test.go New comprehensive test suite covering all scenarios (with/without/none reactions)
pkg/workflow/push_to_pull_request_branch_test.go Added reaction: rocket to existing test to ensure env vars are present
.github/workflows/*.lock.yml Regenerated lock files removing undefined comment env var references from workflows without reactions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot merge main, lint, fix tests

Copilot AI and others added 2 commits November 13, 2025 11:12
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 13, 2025

@copilot merge main, lint, fix tests

Completed all tasks:

  • ✅ Merged main branch (commit 53b85c8)
  • ✅ Lint passed (all formatting and validation checks)
  • ✅ Tests fixed and passing (all unit tests pass including new merge changes)

The merge brought in recent changes including fuzz testing, documentation improvements, and safe output refactoring. All tests pass successfully. (commit 4baedb8)

Copilot AI requested a review from pelikhan November 13, 2025 11:18
@pelikhan pelikhan merged commit b74c48f into main Nov 13, 2025
41 checks passed
@pelikhan pelikhan deleted the copilot/fix-undefined-property-error branch November 13, 2025 11:20
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.

[task] Fix expression_undefined_property error in developer-docs-consolidator workflow

3 participants