Skip to content

[plan] Refactor update handlers and factory generator to factory pattern #8104

@github-actions

Description

@github-actions

Objective

Convert the update handlers and their factory generator to use the factory pattern.

Context

This is Phase 4 of the safe output manager refactoring (#8098). These handlers update existing GitHub resources rather than creating new ones.

Dependencies

  • Requires: #aw_phase3_complex to be completed

Target Branch

sot (safe output transition)

Files to Refactor

  1. actions/setup/js/update_runner.cjs - Factory generator for update handlers
  2. actions/setup/js/update_issue.cjs - Update existing issues
  3. actions/setup/js/update_discussion.cjs - Update existing discussions

Implementation Pattern

update_runner.cjs (Factory Generator)

This file generates update handler factories dynamically:

async function main(config = {}) {
  // Generate update handler factory
  
  return async function(outputItem, resolvedTemporaryIds) {
    // Resolve target ID (may be temporary)
    // Apply updates to existing resource
    // Return { repo, number }
  };
}

module.exports = { main };

update_issue.cjs & update_discussion.cjs

Use the generated factory pattern from update_runner.cjs.

Config Parameters

  • allowed_fields - Whitelisted fields for updates
  • require_confirmation - Require confirmation before updates
  • max_updates - Maximum updates per workflow

Testing

# Run update handler tests
npm test -- update_runner.test.cjs
npm test -- update_issue.test.cjs
npm test -- update_discussion.test.cjs

# Integration test
npm test -- safe_output_handler_manager.test.cjs

Acceptance Criteria

  • All update handlers use factory pattern
  • Factory generator works correctly
  • Temporary ID resolution works for targets
  • No direct process.env access
  • All existing tests pass
  • Config properly passed through
    Related to Safe output manager #8098

AI generated by Plan Command for #8098

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions