Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 26, 2025

Only create SafeOutputsConfig when there are safe jobs to populate

This change optimizes the SafeOutputs initialization logic to only create a new SafeOutputsConfig instance when there are actually safe jobs to populate (len(includedSafeJobs) > 0). Previously, the code would always create an empty SafeOutputsConfig even when there were no safe jobs to populate, which was unnecessary.

Changes Made:

Optimization:

  • Modified the condition for creating SafeOutputsConfig to check len(includedSafeJobs) > 0
  • Added null check for workflowData.SafeOutputs before populating jobs
  • Prevents creation of empty SafeOutputsConfig instances when not needed

Logic:

  • Only creates SafeOutputsConfig when there are actual safe jobs to populate
  • Maintains the same functionality but reduces unnecessary object creation
  • Ensures safer access by checking for null before accessing SafeOutputs.Jobs

This addresses the code review feedback to make the SafeOutputs creation more efficient and only allocate memory when necessary.

Original prompt

Move safe-jobs front matter section under safe-outputs as jobs.

safe-outputs:
   jobs: # new location
     ...
  • update schema
  • update parser

✨ 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 changed the title [WIP] Move safe-jobs front matter section under safe-outputs as jobs. safe-outputs: jobs: # new location ... - update schema - update parser Move safe-jobs frontmatter section under safe-outputs as jobs Sep 26, 2025
Copilot AI requested a review from pelikhan September 26, 2025 04:26
@pelikhan
Copy link
Contributor

@copilot remove SafeJobs field from WorkflowData and use SafeOutputs.Jobs instead. This should simplify checks if safe-outputs feature is enabled.

Copy link
Contributor Author

Copilot AI commented Sep 26, 2025

@copilot remove SafeJobs field from WorkflowData and use SafeOutputs.Jobs instead. This should simplify checks if safe-outputs feature is enabled.

Completed in commit dc1b45d. Removed the SafeJobs field from WorkflowData struct and updated all code to use SafeOutputs.Jobs instead. This simplifies the structure by having a single source of truth for safe-outputs configuration, making checks like HasSafeOutputsEnabled(safeOutputs) work for both regular safe-outputs and safe-jobs.

Copilot AI changed the title Move safe-jobs frontmatter section under safe-outputs as jobs Move safe-jobs frontmatter section under safe-outputs as jobs and refactor internal data structure Sep 26, 2025
…ty and error handling

- Simplified environment variable checks and JSON parsing in create_discussion.js and create_issue.js.
- Enhanced logging for better debugging and user feedback.
- Streamlined the process of creating discussions and issues, including handling related issues and comments.
- Improved handling of discussion categories and issue labels.
- Added checks for repository settings to ensure discussions and issues can be created.
@pelikhan pelikhan marked this pull request as ready for review September 26, 2025 06:21
@pelikhan pelikhan merged commit c86d676 into main Sep 26, 2025
15 of 16 checks passed
@pelikhan pelikhan deleted the copilot/fix-39eac2c3-8998-4ac8-aab4-033825814d65 branch September 26, 2025 06:21
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