Skip to content

Replace console.error/warn with core.error/warn in JavaScript actions#728

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-945cfdc7-43f8-44f4-8292-7e6fee2c4fb9
Sep 11, 2025
Merged

Replace console.error/warn with core.error/warn in JavaScript actions#728
pelikhan merged 2 commits intomainfrom
copilot/fix-945cfdc7-43f8-44f4-8292-7e6fee2c4fb9

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 11, 2025

Updated all JavaScript code used in github-script actions to use the proper GitHub Actions core utilities (core.error and core.warn) instead of console methods (console.error and console.warn).

Problem

JavaScript code in github-script actions was using console logging methods which don't integrate properly with GitHub Actions logging infrastructure. This means:

  • Error/warning messages weren't properly captured in Actions logs
  • No integration with Actions annotations and job summaries
  • Inconsistent logging behavior compared to other Actions utilities

Changes

Files Modified:

  • pkg/workflow/js/collect_ndjson_output.cjs - Replaced console.error with core.error for file write failures
  • pkg/workflow/js/add_reaction_and_edit_comment.cjs - Replaced console.warn with core.warn for comment editing failures
  • pkg/workflow/js/collect_ndjson_output.test.cjs - Updated test expectations to match new logging behavior

Example of changes:

// Error logging
- console.error(`Failed to write agent output file: ${error.message}`);
+ core.error(`Failed to write agent output file: ${error.message}`);

// Warning logging  
- console.warn("Failed to edit comment with workflow link:", errorMessage);
+ core.warn("Failed to edit comment with workflow link:", errorMessage);

Benefits

  • Proper Actions integration: Error/warning messages now appear correctly in GitHub Actions logs with proper formatting and annotations
  • Consistency: All JavaScript code now follows GitHub Actions logging conventions
  • Better debugging: Errors are properly captured and can be surfaced in job summaries and annotations
  • Framework compliance: Aligns with Actions best practices for logging and error handling

Testing

  • All existing tests continue to pass (294/294 JavaScript tests, all Go tests)
  • Updated test expectations to verify core.error/core.warn usage instead of console methods
  • Verified no remaining console.error or console.warn usage in production JavaScript code
  • Code formatting and linting checks pass

The changes are minimal and surgical - only the specific logging calls were modified while preserving all existing functionality and behavior.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build485625254/b278/cli.test -test.testlogfile=/tmp/go-build485625254/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build525063829/b278/cli.test -test.testlogfile=/tmp/go-build525063829/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Review all JavaScript to be inserted in actions/github-script and make sure - core.error is used instead of console.error - core.warn is used instead of console.warn - update all tests after changes Replace console.error/warn with core.error/warn in JavaScript actions Sep 11, 2025
Copilot AI requested a review from pelikhan September 11, 2025 05:45
@pelikhan pelikhan marked this pull request as ready for review September 11, 2025 05:47
@pelikhan pelikhan merged commit 9ab5b79 into main Sep 11, 2025
9 checks passed
@pelikhan pelikhan deleted the copilot/fix-945cfdc7-43f8-44f4-8292-7e6fee2c4fb9 branch September 11, 2025 05:49
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