Skip to content

[plan] Refactor medium complexity safe output handlers to factory pattern #8102

@github-actions

Description

@github-actions

Objective

Convert medium complexity safe output handlers to use the factory pattern, building on the pattern established in Phase 1.

Context

This is Phase 2 of the safe output manager refactoring (#8098). These handlers are more complex than Phase 1 but simpler than create_issue.

Dependencies

  • Requires: #aw_phase1_simple to be completed (establishes pattern)

Target Branch

sot (safe output transition)

Handlers to Refactor

  1. actions/setup/js/add_comment.cjs
  2. actions/setup/js/create_discussion.cjs

Implementation Pattern

Follow the factory pattern established in Phase 1:

async function main(config = {}) {
  // Initialize with config from JSON (no env vars)
  
  return async function(outputItem, resolvedTemporaryIds) {
    // Process single message
    // Resolve any temporary ID references
    // Return { temporaryId?, repo, number }
  };
}

module.exports = { main };

Special Considerations

add_comment.cjs

  • Handles comments on issues, PRs, and discussions
  • May need to resolve parent temporary IDs
  • Config: max, hide_older_comments

create_discussion.cjs

  • Creates new discussions
  • Returns temporary ID for new discussions
  • Config: max, category_id, repository_id

Testing

# Run handler tests
npm test -- add_comment.test.cjs
npm test -- create_discussion.test.cjs

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

Acceptance Criteria

  • Both handlers use factory pattern
  • Temporary ID resolution works correctly
  • No direct process.env access in handlers
  • All existing tests pass
  • Config properly passed through from JSON
    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