Skip to content

Fix missing-tool JavaScript JSON parsing to handle agent-output.json schema correctly#458

Merged
pelikhan merged 3 commits intomainfrom
copilot/fix-json-parsing-issue
Sep 5, 2025
Merged

Fix missing-tool JavaScript JSON parsing to handle agent-output.json schema correctly#458
pelikhan merged 3 commits intomainfrom
copilot/fix-json-parsing-issue

Conversation

Copy link
Contributor

Copilot AI commented Sep 5, 2025

Problem

The missing_tool.cjs file was incorrectly handling the agent output JSON, causing a runtime error when processing missing-tool reports:

Agent output length: 4306
Maximum reports allowed: 5
Parsed agent output with undefined entries
Error: Error processing missing-tool reports: TypeError: parsedData is not iterable

Root Cause

The missing-tool JavaScript was parsing agent output as a direct JSON array:

const parsedData = JSON.parse(agentOutput);
// Then trying to iterate: for (const entry of parsedData)

However, according to the agent-output.json schema, the agent output should be structured as:

{
  "items": [...],
  "errors": [...]
}

All other .cjs files in the codebase (like create_issue.cjs, create_security_report.cjs, etc.) correctly handle this schema format, but missing_tool.cjs was expecting a raw array format.

Solution

Updated missing_tool.cjs to parse the agent output according to the correct schema:

// Parse the validated output JSON
let validatedOutput;
try {
  validatedOutput = JSON.parse(agentOutput);
} catch (error) {
  core.error(`Error parsing agent output JSON: ${error.message}`);
  return;
}

if (!validatedOutput.items || !Array.isArray(validatedOutput.items)) {
  core.info("No valid items found in agent output");
  return;
}

// Process all parsed entries
for (const entry of validatedOutput.items) {
  // ... existing processing logic
}

Testing

  • Updated all test cases in missing_tool.test.cjs to provide data in the correct schema format
  • Added new test case for empty items array scenario
  • All 10 missing-tool tests pass ✅
  • All 268 JavaScript tests pass ✅
  • All 78 Go tests pass ✅
  • Manual verification confirms the fix resolves the "parsedData is not iterable" error

The fix is minimal and surgical - only changing the JSON parsing logic while preserving all existing functionality and maintaining consistency with the rest of the codebase.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build490189584/b278/cli.test -test.testlogfile=/tmp/go-build490189584/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits September 5, 2025 16:43
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ectly

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Review the safe output .cjs files where they parse the agent output files. The agent output matches the agent-output.json schema and should be treated as valid JSON. The missing-tool javascript is incorrectly handling this file. - javascript ``` ... Fix missing-tool JavaScript JSON parsing to handle agent-output.json schema correctly Sep 5, 2025
Copilot AI requested a review from pelikhan September 5, 2025 16:49
@pelikhan pelikhan marked this pull request as ready for review September 5, 2025 17:17
@pelikhan pelikhan merged commit 0d56821 into main Sep 5, 2025
18 checks passed
@pelikhan pelikhan deleted the copilot/fix-json-parsing-issue branch September 5, 2025 17:19
Copilot AI added a commit that referenced this pull request Nov 26, 2025
Added timeout-minutes and strict mode to:
- ai-triage-campaign.md: timeout-minutes: 10, strict: true
- daily-team-status.md: timeout-minutes: 10, strict: true
- dev.md: timeout-minutes: 5, strict: false (dev/test workflow)
- example-permissions-warning.md: timeout-minutes: 5 (strict: false already)
- github-mcp-structural-analysis.md: timeout-minutes: 15 (strict: false already)
- issue-triage-agent.md: timeout-minutes: 5, strict: true
- notion-issue-summary.md: timeout-minutes: 5 (strict: true already)
- weekly-issue-summary.md: timeout-minutes: 20, strict: true

Timeouts set based on workflow complexity:
- 5 min: Simple/standard workflows
- 10-15 min: Complex analysis
- 20 min: Data-intensive reporting

Closes #458

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pelikhan added a commit that referenced this pull request Nov 26, 2025
* Initial plan

* Add timeout and strict mode configuration to 8 workflows

Added timeout-minutes and strict mode to:
- ai-triage-campaign.md: timeout-minutes: 10, strict: true
- daily-team-status.md: timeout-minutes: 10, strict: true
- dev.md: timeout-minutes: 5, strict: false (dev/test workflow)
- example-permissions-warning.md: timeout-minutes: 5 (strict: false already)
- github-mcp-structural-analysis.md: timeout-minutes: 15 (strict: false already)
- issue-triage-agent.md: timeout-minutes: 5, strict: true
- notion-issue-summary.md: timeout-minutes: 5 (strict: true already)
- weekly-issue-summary.md: timeout-minutes: 20, strict: true

Timeouts set based on workflow complexity:
- 5 min: Simple/standard workflows
- 10-15 min: Complex analysis
- 20 min: Data-intensive reporting

Closes #458

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

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Jan 4, 2026
Added #nosec G304 comment with security justification for os.ReadFile call.
The path is already validated through:
1. filepath.Clean() normalization
2. Absolute path resolution
3. filepath.Rel() boundary checking

This is a false positive as the code already implements proper path
traversal protection (lines 414-441).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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