Refactor duplicate JSON/JSONL parsing logic into shared utility#4574
Merged
Refactor duplicate JSON/JSONL parsing logic into shared utility#4574
Conversation
- Created parseLogEntries() function in log_parser_shared.cjs - Extracted ~100 lines of duplicate parsing code from both parsers - Updated parse_claude_log.cjs to use shared function (-47 lines) - Updated parse_copilot_log.cjs to use shared function (-38 lines) - Added comprehensive unit tests for parseLogEntries() - All existing tests pass without modification Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor duplicate JSON/JSONL parsing fallback in log parsers
Refactor duplicate JSON/JSONL parsing logic into shared utility
Nov 22, 2025
Contributor
|
✅ Agentic Changeset Generator completed successfully. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR successfully refactors duplicate JSON/JSONL parsing logic from two log parser files into a shared utility function, eliminating 85 lines of duplicate code while maintaining functionality and adding comprehensive test coverage.
Key Changes
- Created shared utility: New
parseLogEntries()function inlog_parser_shared.cjshandles JSON array, JSONL, and mixed format parsing with consistent error handling - Refactored parsers: Both
parse_claude_log.cjsandparse_copilot_log.cjsnow use the shared function, reducing code duplication - Comprehensive testing: Added 11 unit tests covering JSON arrays, JSONL, mixed formats, edge cases, and error conditions
Reviewed changes
Copilot reviewed 84 out of 84 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/js/log_parser_shared.cjs |
Added parseLogEntries() function with robust JSON/JSONL parsing logic that returns null on failure |
pkg/workflow/js/parse_claude_log.cjs |
Removed 47 lines of duplicate parsing code, replaced with shared function call |
pkg/workflow/js/parse_copilot_log.cjs |
Removed 38 lines of duplicate parsing code, replaced with shared function call |
pkg/workflow/js/log_parser_shared.test.cjs |
Added 11 comprehensive test cases covering all parsing scenarios |
.github/workflows/*.lock.yml |
Bundled workflow files updated with inlined shared function across 60+ workflows |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both
parse_claude_log.cjsandparse_copilot_log.cjscontained ~50 lines of identical JSON/JSONL parsing fallback logic, creating maintenance burden and divergence risk.Changes
parseLogEntries()inlog_parser_shared.cjsto handle JSON array, JSONL, and mixed format parsing with debug logsExample
Before (duplicated in both parsers):
After:
Net reduction: 85 lines of duplicate code eliminated.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.