Skip to content

Refactor missing_tool to integrated safe output handler#9322

Merged
pelikhan merged 5 commits intomainfrom
copilot/fix-safe-outputs-error
Jan 8, 2026
Merged

Refactor missing_tool to integrated safe output handler#9322
pelikhan merged 5 commits intomainfrom
copilot/fix-safe-outputs-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 8, 2026

Refactor missing_tool to integrated safe output handler

Problem Analysis

The warning "No handler loaded for message type 'missing_tool'" occurred because missing_tool messages weren't properly integrated into the safe output handler system.

Solution

Refactored missing_tool.cjs from a standalone job handler to a proper safe output handler following the handler factory pattern used by other handlers like create_issue.cjs.

Changes Made

  • Analyze the error and understand the flow
  • Refactor missing_tool.cjs to follow handler factory pattern
    • Changed from standalone main() to factory pattern main(config) returning message handler
    • Handler processes individual messages instead of batch processing
    • Validates required fields (tool, reason)
    • Respects max count configuration
  • Wire up handler in safe_output_handler_manager.cjs
    • Added missing_tool: "./missing_tool.cjs" to HANDLER_MAP
    • Removed "missing_tool" from STANDALONE_STEP_TYPES
  • Update test coverage
    • Rewrote tests to match handler factory pattern
    • Tests validate message processing, field validation, max count, and timestamps
    • All 7 handler tests passing
  • Merge main branch and format JavaScript
    • Branch already up to date with main
    • Formatted JavaScript files (removed trailing whitespace)
    • All linting checks passing

Test Results

  • ✅ safe_output_handler_manager tests: 17 passed | 3 skipped
  • ✅ missing_tool handler tests: 7 passed
  • ✅ All JavaScript formatting and linting checks pass

Impact

  • missing_tool messages are now processed through the handler manager like other safe output types
  • Eliminates spurious warning messages
  • Maintains consistent architecture across all safe output handlers
  • No breaking changes to message format or behavior
Original prompt

Analyze error in safe outputs step:
✓ Loaded and initialized handler for: create_pull_request
Loaded 1 handler(s)
Processing 1 message(s) in order of appearance...
Warning: ⚠️ No handler loaded for message type 'missing_tool' (message 1/1). The message will be skipped. This may happen if the safe output type is not configured in the workflow's safe-outputs section.


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

- missing_tool messages are handled by a dedicated standalone job
- These messages should be silently skipped by the handler manager
- Added test to verify missing_tool messages don't trigger warnings
- All JavaScript and missing_tool-related Go tests pass

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error in safe outputs step handler Fix missing_tool warning in safe output handler manager Jan 8, 2026
Copilot AI requested a review from mnkiefer January 8, 2026 06:37
@mnkiefer
Copy link
Copy Markdown
Collaborator

mnkiefer commented Jan 8, 2026

@copilot: When was this error instroduced?

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Jan 8, 2026

@copilot review the available JavaScript files, specifically missing_tool.cjs which is a handler for safe output entries. Wire up this file in the safe output manager.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 8, 2026

@copilot: When was this error instroduced?

The error was introduced in commit 9850a9f (PR #9321, merged January 7, 2026 at 22:16:23 -0800). That commit added the missing_tool safe output type and its standalone handler (missing_tool.cjs), but didn't add "missing_tool" to the STANDALONE_STEP_TYPES set in safe_output_handler_manager.cjs.

@mnkiefer mnkiefer marked this pull request as ready for review January 8, 2026 06:53
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Jan 8, 2026

@copilot refactor missing_tool.cjs to integrate as a non-standalone handler

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 8, 2026

@copilot review the available JavaScript files, specifically missing_tool.cjs which is a handler for safe output entries. Wire up this file in the safe output manager.

I need clarification on the requested change. Currently, missing_tool.cjs is a standalone job handler (not following the handler factory pattern). My original fix added "missing_tool" to STANDALONE_STEP_TYPES to suppress the warning.

Are you asking me to:

  1. Keep it as a standalone step but also add it to HANDLER_MAP (dual mode)?
  2. Refactor missing_tool.cjs to follow the handler factory pattern like other handlers (e.g., create_issue.cjs)?
  3. Something else?

The current architecture has missing_tool messages processed by a dedicated standalone job, while create_missing_tool_issue messages are processed through the handler manager. Which approach should I take?

- Converted missing_tool.cjs to handler factory pattern
- Added missing_tool to HANDLER_MAP in safe_output_handler_manager.cjs
- Removed missing_tool from STANDALONE_STEP_TYPES
- Updated tests to match new handler pattern
- All JavaScript tests passing (24 tests)

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

pelikhan commented Jan 8, 2026

@copilot Refactor missing_tool.cjs to follow the handler factory pattern like other handlers (e.g., create_issue.cjs)?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 8, 2026

@copilot refactor missing_tool.cjs to integrate as a non-standalone handler

Refactored missing_tool.cjs to non-standalone handler in commit 2d8cd6a. The handler now follows the factory pattern like other safe output handlers, processing individual messages through the handler manager instead of as a standalone job. All tests passing.

Copilot AI changed the title Fix missing_tool warning in safe output handler manager Refactor missing_tool to integrated safe output handler Jan 8, 2026
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 8, 2026

@copilot Refactor missing_tool.cjs to follow the handler factory pattern like other handlers (e.g., create_issue.cjs)?

Yes, that's exactly what was done in commit 2d8cd6a. The refactoring:

  • Follows the handler factory pattern with main(config) returning a message handler function
  • Includes proper TypeScript typedefs (HandlerFactoryFunction)
  • Processes individual messages with handleMissingTool(message, resolvedTemporaryIds)
  • Added to HANDLER_MAP and removed from STANDALONE_STEP_TYPES
  • All tests updated and passing

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Jan 8, 2026

@copilot merge main, format, lint js

- Ran npm run format:cjs to format all JavaScript files
- Removed trailing whitespace from missing_tool.cjs and missing_tool.test.cjs
- All tests passing (24 passed | 3 skipped)

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

Copilot AI commented Jan 8, 2026

@copilot merge main, format, lint js

Completed in commit a3e4a73:

  • Branch already up to date with main (merged in 1a6178e)
  • Formatted all JavaScript files (removed trailing whitespace)
  • All linting checks passing
  • All tests passing (24 passed | 3 skipped)

@pelikhan pelikhan merged commit 6dbd1fe into main Jan 8, 2026
79 checks passed
@pelikhan pelikhan deleted the copilot/fix-safe-outputs-error branch January 8, 2026 07:27
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.

3 participants