Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 3, 2026

Implementation Plan: Discussion-to-Issue Fallback

  • Add FallbackToIssue field to CreateDiscussionsConfig struct in Go
  • Update parseDiscussionsConfig to handle the new field with default true
  • Pass fallback_to_issue config to create_discussion.cjs via handler config
  • Modify create_discussion.cjs to detect permissions errors and fallback to create_issue
  • Add footer note when creating issue as fallback
  • Write tests for the new functionality
  • Run validation (format, lint, test)
  • Refactor duplicated fallback logic into helper function
  • Manual testing

Summary

This PR adds an option to fallback to safe-outputs.create-issue when safe-outputs.create-discussion fails with a permissions issue. The default value is true but it can be turned off using:

safe-outputs:
  create-discussion:
    fallback-to-issue: false

Implementation Details

  1. Go Configuration: Added FallbackToIssue *bool field to CreateDiscussionsConfig with default value of true
  2. JavaScript Handler: Modified create_discussion.cjs to:
    • Initialize the create_issue handler when fallback is enabled
    • Detect permissions errors (Resource not accessible, Insufficient permissions, etc.)
    • Fallback to creating an issue with a note explaining it was meant to be a discussion
    • Refactored duplicated fallback logic into handleFallbackToIssue helper function for better maintainability
  3. Footer Note: When an issue is created as fallback, it includes:
    > **Note:** This was intended to be a discussion, but discussions could not be created due to permissions issues. This issue was created as a fallback.
    

Testing

  • Added TestParseDiscussionsConfigFallbackToIssue test to verify default and explicit configuration
  • All unit tests pass
  • Linting passes
Original prompt

Add an option to fallback to 'safe-outputs.create-issue' when 'safe-outputs.create-discussion' fails with a permissions issue. The default value is "true" but it can be turned off using a field.

   safe-outputs:
     create-discussion: # fails easily because of permissions
        fallback-to-issue: false

Reuse the javascript existing code to create issue. Add a footer note that it was meant to be a discussion but we were unable to the create the discussion.


✨ 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 2 commits February 3, 2026 19:41
- Added FallbackToIssue field to CreateDiscussionsConfig struct (default: true)
- Updated parseDiscussionsConfig to set default value
- Added fallback_to_issue to handler config builder
- Updated create_discussion.cjs to handle fallback logic when permissions errors occur
- Reuses existing create_issue handler for fallback
- Adds note to issue body when created as fallback

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

pelikhan commented Feb 3, 2026

@copilot keep working

- Added TestParseDiscussionsConfigFallbackToIssue test
- Recompiled all workflow lock files with updated configuration
- All tests pass, linting passes
- Ready for review

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

Copilot AI commented Feb 3, 2026

@copilot keep working

Completed the implementation! All tasks from the checklist are now done:

✅ Added FallbackToIssue field with default true
✅ Configuration parsing and handler config building
✅ JavaScript fallback logic with permissions error detection
✅ Footer note on fallback issues
✅ Tests added (TestParseDiscussionsConfigFallbackToIssue)
✅ All validation passed (format, lint, unit tests)
✅ Workflows recompiled

Commit: c64c24d

The feature is ready for review. When a discussion creation fails due to permissions issues, it will automatically fallback to creating an issue with a note explaining it was meant to be a discussion. Users can disable this with fallback-to-issue: false in their configuration.

Copilot AI changed the title [WIP] Add fallback to create issue on discussion failure Add fallback to create issue on discussion failure Feb 3, 2026
@pelikhan pelikhan marked this pull request as ready for review February 3, 2026 21:16
Copilot AI review requested due to automatic review settings February 3, 2026 21:16
const errorMessage = getErrorMessage(error);

// Check if this is a permissions error and fallback is enabled
if (fallbackToIssue && createIssueHandler && isPermissionsError(errorMessage)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot refactor into helper function to avoid duplication

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored into handleFallbackToIssue helper function. Both error paths (fetching discussion info and creating discussion) now use the same helper, reducing code duplication by ~40 lines.

Commit: 2339840

Copy link
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 implements a fallback mechanism for the safe-outputs.create-discussion handler to automatically create issues when discussion creation fails due to permissions errors. The feature is enabled by default but can be disabled via configuration.

Changes:

  • Added FallbackToIssue configuration field (default: true) to enable/disable fallback behavior
  • Implemented permissions error detection and automatic fallback to create_issue handler in JavaScript
  • Added fallback note to issues created as discussion substitutes
  • Updated all workflow lock files to include the new configuration parameter

Reviewed changes

Copilot reviewed 65 out of 65 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/workflow/create_discussion.go Added FallbackToIssue field, default value handling, and configuration logging
pkg/workflow/create_discussion_validation_test.go Added tests for fallback-to-issue configuration parsing and defaults
pkg/workflow/compiler_safe_outputs_config.go Updated handler registry to include fallback_to_issue in config builder
actions/setup/js/create_discussion.cjs Implemented isPermissionsError detection, create_issue handler initialization, and fallback logic with note appending
.github/workflows/*.lock.yml Regenerated workflow files with fallback_to_issue:true in handler configs
.github/workflows/go.mod Added empty require block (likely formatting)
.github/dependabot.yml Added gomod ecosystem monitoring for .github/workflows directory
Comments suppressed due to low confidence (2)

actions/setup/js/create_discussion.cjs:415

  • The fallback note message is duplicated in two places (lines 250 and 415). Consider extracting this to a constant at the module level to ensure consistency and make future updates easier. For example:
const FALLBACK_NOTE = `\n\n---\n\n> **Note:** This was intended to be a discussion, but discussions could not be created due to permissions issues. This issue was created as a fallback.\n`;

This would also make it easier to test the exact message format.
actions/setup/js/create_discussion.cjs:179

  • There's a potential issue with the max count tracking when fallback occurs. The processedCount is incremented at line 179 before the discussion creation is attempted. When a fallback to create_issue happens, the create_issue handler has its own internal processedCount that also gets incremented.

This means:

  1. The create_discussion handler increments its count
  2. The create_issue handler (initialized with the same max value) increments its own count

If multiple fallbacks occur, the create_issue handler could reach its max limit independently, even though the create_discussion handler may still have quota remaining. This could lead to confusing behavior where some fallbacks succeed and others fail with "max count reached" errors.

Consider one of these approaches:

  1. Pass a higher or unlimited max count to the create_issue handler since it's only used for fallback
  2. Share the same counter between both handlers
  3. Document this behavior clearly if it's intentional

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

Comment on lines +4 to +5
require (
)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The empty require() block appears to be unintentional formatting. The .github/workflows/go.mod file originally had no require block at all, and this change adds an empty one. Consider either:

  1. Removing the empty require block to keep the file minimal, or
  2. If there are dependencies to add, include them in this block

If this file is auto-generated or managed by a tool, please verify the tool is working correctly.

Copilot uses AI. Check for mistakes.
Comment on lines +96 to +111
/**
* Checks if an error is a permissions-related error
* @param {string} errorMessage - The error message to check
* @returns {boolean} True if the error is permissions-related
*/
function isPermissionsError(errorMessage) {
return (
errorMessage.includes("Resource not accessible") ||
errorMessage.includes("Insufficient permissions") ||
errorMessage.includes("Bad credentials") ||
errorMessage.includes("Not Authenticated") ||
errorMessage.includes("requires authentication") ||
errorMessage.includes("Discussions not enabled") ||
errorMessage.includes("Failed to fetch repository information")
);
}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The new isPermissionsError function and the fallback mechanism lack test coverage. While Go tests were added for configuration parsing, there are no JavaScript tests verifying:

  1. The isPermissionsError function correctly identifies various permission error messages
  2. The fallback to create_issue works correctly when permissions errors occur
  3. The fallback note is properly appended to the issue body
  4. The fallback mechanism correctly handles cases when create_issue also fails

Consider adding unit tests for this functionality in a new test file such as create_discussion.test.cjs.

Copilot uses AI. Check for mistakes.
Comment on lines +155 to +161
createIssueHandler = await createIssueMain({
...config, // Pass through most config
title_prefix: titlePrefix,
max: maxCount,
expires: expiresHours,
});
}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

When initializing the create_issue handler for fallback, the configuration is passed using spread operator which may not properly handle all configuration values. Specifically:

  1. The labels field in the config object might be an array in create_discussion but create_issue expects it to be either an array or comma-separated string
  2. The allowed_repos, allowed_labels and target-repo fields are spread from the original config which is correct
  3. However, discussion-specific fields like category, close_older_discussions, and required_category are also being spread and may cause confusion

Consider being more explicit about which configuration fields should be passed to create_issue to avoid unintended behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +161 to +164
// Add fallback-to-issue flag
if data.SafeOutputs.CreateDiscussions.FallbackToIssue != nil && *data.SafeOutputs.CreateDiscussions.FallbackToIssue {
customEnvVars = append(customEnvVars, " GH_AW_DISCUSSION_FALLBACK_TO_ISSUE: \"true\"\n")
}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The environment variable GH_AW_DISCUSSION_FALLBACK_TO_ISSUE is set here but is not actually used by the JavaScript handler. The create_discussion.cjs handler reads the fallback_to_issue configuration from the config object passed to its main() function, which comes from the GH_AW_SAFE_OUTPUTS_HANDLER_CONFIG JSON (set via addHandlerManagerConfigEnvVar in compiler_safe_outputs_config.go).

This environment variable is redundant and could be removed to avoid confusion. The configuration is already properly passed through the handler config JSON at line 144 in compiler_safe_outputs_config.go via AddBoolPtr("fallback_to_issue", c.FallbackToIssue).

Copilot uses AI. Check for mistakes.
- Created handleFallbackToIssue helper function to consolidate duplicated fallback logic
- Both error paths (fetch discussion info and create discussion) now use the helper
- Added contextMessage parameter for specific error context
- Reduces code duplication by ~40 lines

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

github-actions bot commented Feb 4, 2026

🔍 PR Triage Results

Category: feature | Risk: medium | Priority: 60/100

Scores Breakdown

  • Impact: 30/50 - Feature adding fallback mechanism for discussion creation failures; 233 additions, 60 deletions across 65 files (many lock files); improves robustness; handles permissions errors gracefully
  • Urgency: 15/30 - Created 5.0 hours ago; not draft (ready for review); 6 commits; 2 comments, 6 review comments; assigned to pelikhan; reliability improvement but not critical
  • Quality: 15/20 - CI status unknown; ready for review (not draft); excellent description with implementation plan checklist; includes tests; active review process (6 review comments); refactored duplicated logic into helper function

📋 Recommended Action: batch_review

Well-implemented feature that improves reliability by adding a fallback mechanism. The PR includes tests, good documentation, and has undergone review (6 review comments addressed). While ready for merge, it's not urgent enough for fast-track. Can be reviewed alongside other reliability improvement PRs. The refactoring into helper functions shows good code quality.


Triaged by PR Triage Agent on 2026-02-04T00:35:56Z

AI generated by PR Triage Agent

@pelikhan pelikhan added the smoke label Feb 4, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

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

Smoke test complete - 9/10 tests passed, issue created, discussion commented

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

Agent Container Tool Check ✅

All required development tools are available in the agent container:

Tool Status Version
bash GNU bash 5.2.21
sh Available
git 2.52.0
jq 1.7
yq 4.x
curl 8.5.0
gh 2.86.0
node v24.13.0
python3 3.13.11
go 1.24.12
java Available
dotnet Available

Result: 12/12 tools available ✅

The agent container environment is properly configured with all necessary development tools for workflow execution.

AI generated by Agent Container Smoke Test

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

GitHub MCP (last 2 merged PRs): ✅ Update Docker image version in workflow; [WIP] Update Multi-Device Docs Tester .lock.yml for version v0.0.98
safeinputs-gh PR list: ✅ Download agent file from GitHub on demand, reference prompts via URLs; Use AWF --enable-chroot mode and remove unnecessary --mount and --env flags
Serena activate: ✅
Playwright title check: ❌
Tavily search: ✅
File write: ✅
Bash cat verify: ✅
Discussion query+comment: ✅
Build gh-aw: ✅
Overall status: FAIL

AI generated by Smoke Codex

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

🧪 Smoke Test Results

PR #13612: Download agent file from GitHub on demand
PR #13576: Use AWF --enable-chroot mode

Test Results:

  • ✅ GitHub MCP (2 merged PRs)
  • ✅ Safe Inputs GH CLI (2 PRs queried)
  • ✅ Serena MCP (project activated)
  • ✅ File Writing (test file created)
  • ✅ Bash Tool (file verified)
  • ✅ Discussion Interaction (comment added)
  • ✅ Build gh-aw (binary built successfully)
  • ✅ Workflow Dispatch (haiku triggered)

Overall: PASS

@pelikhan

AI generated by Smoke Copilot

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2026

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

@pelikhan pelikhan merged commit 329ad34 into main Feb 4, 2026
125 checks passed
@pelikhan pelikhan deleted the copilot/add-fallback-to-issue-option branch February 4, 2026 03:29
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.

2 participants