Skip to content

fix(rag): defensive import for execa in auto-update#1086

Open
svg153 wants to merge 1 commit into
manufosela:mainfrom
svg153:fix/rag-defensive-execa
Open

fix(rag): defensive import for execa in auto-update#1086
svg153 wants to merge 1 commit into
manufosela:mainfrom
svg153:fix/rag-defensive-execa

Conversation

@svg153

@svg153 svg153 commented Jun 14, 2026

Copy link
Copy Markdown

Summary

  • Make execa import dynamic to avoid crashes when kj is used as external CLI
  • Skip RAG drift check gracefully when execa is not available

Related

  • KJC-BUG-0082

Copilot AI review requested due to automatic review settings June 14, 2026 02:11
@changeset-bot

changeset-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8f7055b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Makes execa an optional dependency so RAG auto-update doesn’t fail in projects that don’t install it.

Changes:

  • Replaces static execa import with a defensive dynamic import.
  • Skips the drift check when execa isn’t available and returns a reason.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rag/auto-update.js Outdated
Comment on lines +12 to +15
// Defensive import — execa may not be available in projects that only
// use kj as an external CLI (they don't list it in their own deps).
let execa;
try { execa = (await import("execa")).execa; } catch { execa = null; }
Comment thread src/rag/auto-update.js Outdated
// Defensive import — execa may not be available in projects that only
// use kj as an external CLI (they don't list it in their own deps).
let execa;
try { execa = (await import("execa")).execa; } catch { execa = null; }
Comment thread src/rag/auto-update.js Outdated
Comment on lines +23 to +24
// execa not available → skip RAG drift check (non-blocking, see KJC-BUG-0082)
if (!execa) return { skipped: true, reason: "execa not available" };
- Make execa import dynamic to avoid crashes when kj is used as external CLI
- Skip RAG drift check gracefully when execa is not available
- Fixes KJC-BUG-0082: RAG auto-update fails in projects without execa as direct dependency
@svg153 svg153 force-pushed the fix/rag-defensive-execa branch from 68227c8 to 8f7055b Compare June 14, 2026 02:16
@svg153

svg153 commented Jun 14, 2026

Copy link
Copy Markdown
Author

Resolving Copilot Review Comments

Comment 1 - Lazy-load execa: Changed from top-level await to lazy-loading with caching inside getExeca() function. Module evaluation stays synchronous and execa is only loaded when maybeAutoUpdate is called.

Comment 2 - Error handling: Now only catches module-not-found errors (ERR_MODULE_NOT_FOUND or "Cannot find module"), rethrows other unexpected errors instead of silently swallowing them.

Comment 3 - Logging: Added logger.debug?.("[rag] skipping auto-update: execa not available") when skipping due to missing execa, so it's easier to diagnose in the field.

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