MCPcopy Create free account
hub / github.com/Noumena-Network/code / enhanceGitPullErrorMessages

Function enhanceGitPullErrorMessages

src/utils/plugins/marketplaceManager.ts:649–709  ·  view source on GitHub ↗

* Enhance error messages for git pull failures

(result: {
  code: number
  stderr: string
  error?: string
})

Source from the content-addressed store, hash-verified

647 * Enhance error messages for git pull failures
648 */
649function enhanceGitPullErrorMessages(result: {
650 code: number
651 stderr: string
652 error?: string
653}): { code: number; stderr: string } {
654 if (result.code === 0) {
655 return result
656 }
657
658 // Detect execa timeout kills via the error field (stderr won't contain "timed out"
659 // when the process is killed by SIGTERM — the timeout info is only in error)
660 if (result.error?.includes('timed out')) {
661 const timeoutSec = Math.round(getPluginGitTimeoutMs() / 1000)
662 return {
663 ...result,
664 stderr: `Git pull timed out after ${timeoutSec}s. Try increasing the timeout via CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS environment variable.\n\nOriginal error: ${result.stderr}`,
665 }
666 }
667
668 // Detect SSH host key verification failures (check before the generic
669 // 'Could not read from remote' catch — that string appears in both cases).
670 // OpenSSH emits "Host key verification failed" for BOTH host-not-in-known_hosts
671 // and host-key-has-changed — the latter also includes the "REMOTE HOST
672 // IDENTIFICATION HAS CHANGED" banner, which needs different remediation.
673 if (result.stderr.includes('REMOTE HOST IDENTIFICATION HAS CHANGED')) {
674 return {
675 ...result,
676 stderr: `SSH host key for this marketplace's git host has changed (server key rotation or possible MITM). Remove the stale entry with: ssh-keygen -R <host>\nThen connect once manually to accept the new key.\n\nOriginal error: ${result.stderr}`,
677 }
678 }
679 if (result.stderr.includes('Host key verification failed')) {
680 return {
681 ...result,
682 stderr: `SSH host key verification failed while updating marketplace. The host key is not in your known_hosts file. Connect once manually to add it (e.g., ssh -T git@<host>), or remove and re-add the marketplace with an HTTPS URL.\n\nOriginal error: ${result.stderr}`,
683 }
684 }
685
686 // Detect SSH authentication failures
687 if (
688 result.stderr.includes('Permission denied (publickey)') ||
689 result.stderr.includes('Could not read from remote repository')
690 ) {
691 return {
692 ...result,
693 stderr: `SSH authentication failed while updating marketplace. Please ensure your SSH keys are configured.\n\nOriginal error: ${result.stderr}`,
694 }
695 }
696
697 // Detect network issues
698 if (
699 result.stderr.includes('timed out') ||
700 result.stderr.includes('Could not resolve host')
701 ) {
702 return {
703 ...result,
704 stderr: `Network error while updating marketplace. Please check your internet connection.\n\nOriginal error: ${result.stderr}`,
705 }
706 }

Callers 1

gitPullFunction · 0.85

Calls 1

getPluginGitTimeoutMsFunction · 0.85

Tested by

no test coverage detected