Skip to content

Validate repository features (discussions/issues) during workflow compilation#2347

Merged
pelikhan merged 6 commits intomainfrom
copilot/report-hard-error-workflow-install
Oct 25, 2025
Merged

Validate repository features (discussions/issues) during workflow compilation#2347
pelikhan merged 6 commits intomainfrom
copilot/report-hard-error-workflow-install

Conversation

Copy link
Contributor

Copilot AI commented Oct 25, 2025

Workflows using create-discussion, create-issue, or add-comment with discussion: true now fail at compile time if the target repository doesn't have those features enabled, preventing runtime failures.

Implementation

Validation logic (pkg/workflow/validation.go):

  • validateRepositoryFeatures() - Checks required features during compilation
  • checkRepositoryHasDiscussions() - GraphQL query for discussions status
  • checkRepositoryHasIssues() - REST API query for issues status
  • getCurrentRepository() - Resolves repository from git context via gh CLI

Compiler integration (pkg/workflow/compiler.go):

  • Added validation step after runtime package validation

Coverage:

  • safe-outputs.create-discussion
  • safe-outputs.create-issue
  • safe-outputs.add-comment with discussion: true

Behavior

Validation is graceful:

  • Skips if repository cannot be determined (not in git repo)
  • Logs warnings if API calls fail (auth/network issues)
  • Hard error only when feature is confirmed disabled

Error messages specify the missing feature and remediation:

workflow uses safe-outputs.create-discussion but repository owner/repo does not have 
discussions enabled. Enable discussions in repository settings or remove create-discussion 
from safe-outputs

Testing

  • Unit tests cover all safe-output combinations
  • Integration tests verify API calls when gh CLI authenticated
  • All existing tests pass
Original prompt

This section details on the original issue you should resolve

<issue_title>Report a hard error if you install a workflow that create/comments on discussions into a repo that doesn't have them enabled</issue_title>
<issue_description>See githubnext/agentics#64</issue_description>

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

@Mossaka I think this applies to Issues too @dsyme Yup (though very rare not to have issues enabled!)

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits October 25, 2025 00:26
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…pilation

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Report hard error for workflows on repos without discussions Validate repository features (discussions/issues) during workflow compilation Oct 25, 2025
Copilot AI requested a review from pelikhan October 25, 2025 00:39
@pelikhan pelikhan marked this pull request as ready for review October 25, 2025 00:47
Copilot AI review requested due to automatic review settings October 25, 2025 00:47
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 adds compile-time validation to ensure workflows using discussion or issue-related safe-outputs target repositories with those features enabled. Previously, workflows would fail at runtime if discussions/issues were disabled; now they fail during compilation with actionable error messages.

Key changes:

  • Added repository feature validation during workflow compilation
  • Implemented GitHub API checks for discussions (GraphQL) and issues (REST)
  • Tests cover unit, integration, and real API call scenarios

Reviewed Changes

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

Show a summary per file
File Description
pkg/workflow/validation.go Adds validation functions for checking repository discussions/issues via GitHub APIs
pkg/workflow/repository_features_validation_test.go Unit tests for repository feature validation logic
pkg/workflow/repository_features_validation_integration_test.go Integration tests that verify validation with actual GitHub API calls
pkg/workflow/compiler.go Integrates repository feature validation into the compilation workflow
docs/src/content/docs/reference/frontmatter-full.md Removes commented-out feature flag documentation

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

@github-actions
Copy link
Contributor

Agentic Changeset Generator triggered by this pull request.

@pelikhan pelikhan merged commit 65b4065 into main Oct 25, 2025
38 checks passed
@pelikhan pelikhan deleted the copilot/report-hard-error-workflow-install branch October 25, 2025 00:58
github-actions bot added a commit that referenced this pull request Oct 25, 2025
Update CLI documentation to reflect recent feature additions:

- Document firewall log parsing in --parse flag (PR #2349, #2350)
  - Logs and audit commands now generate firewall.md files
  - JSON output includes firewall analysis

- Update --dependabot documentation (PR #2359)
  - Added pip and Go ecosystem support
  - Clarified command detection patterns

- Add repository feature validation section (PR #2347)
  - Compile validates discussions/issues enabled
  - Prevents runtime failures for incompatible workflows

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

Report a hard error if you install a workflow that create/comments on discussions into a repo that doesn't have them enabled

3 participants