fix(enrichment): don't crash on a missing optional mcp.json or skills/ dir#123
Open
mftnakrsu wants to merge 1 commit into
Open
Conversation
…/ dir loadMcpTools and loadSkills called fs.promises.stat() OUTSIDE their try blocks. fs.promises.stat rejects with ENOENT when the path is absent, so a missing (optional) mcp.json or skills/ directory threw an uncaught ENOENT up through enrichCommand and aborted 'kcagent enrich' — the !stat.isFile()/!stat.isDirectory() guards were dead code for that case. Move the stat() calls inside the existing try blocks and treat ENOENT as 'not configured' (return [] without a spurious warning); other errors still warn. Matches the catch blocks' existing return-[] intent.
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.
What
loadMcpToolsandloadSkills(toolbox/enrichment/src/agent/tools.ts) crashkcagent enrichwhen their optional config inputs are absent.Why
Both functions call
fs.promises.stat()outside theirtryblocks:fs.promises.statrejects withENOENTfor a missing path, so a missingmcp.json/skills/dir throws an uncaught ENOENT up throughenrichCommand, aborting the run — and the!isFile()/!isDirectory()guards never get a chance to return[].Change
Move both
stat()calls inside the existingtryblocks and treatENOENTas "not configured" (return[]silently; other errors still warn). This matches the catch blocks' existing return-[]intent and keeps these inputs genuinely optional.Verification
npx tsc --noEmittype-checks the changed file clean. The only diagnostics in a fresh checkout are pre-existingTS2307: Cannot find module 'kcmd'inagent.ts/command.tsfrom the unbuilt localfile:../mdcodedependency — unrelated to this change.🤖 Generated with Claude Code