{"record":{"id":"a0be2c45f3191287","repo":"abhigyanpatwari/GitNexus","slug":"no-suitable-device-found-for-embedding-model","errorCode":null,"errorMessage":"No suitable device found for embedding model","messagePattern":"No suitable device found for embedding model","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/embedder.ts","lineNumber":252,"sourceCode":"              ? `The configured endpoint (${process.env.HF_ENDPOINT}) may be unreachable.`\n              : `huggingface.co may be unreachable from your network.\\n` +\n                `  Set HF_ENDPOINT to a mirror and retry:\\n` +\n                `    HF_ENDPOINT=https://hf-mirror.com npx gitnexus analyze --embeddings\\n` +\n                `    (Windows: set HF_ENDPOINT=https://hf-mirror.com && npx gitnexus analyze --embeddings)`;\n            throw new Error(`Failed to download embedding model: ${errMsg}\\n  ${endpointHint}`);\n          }\n          if (isDev && (device === 'cuda' || device === 'dml')) {\n            const gpuType = device === 'dml' ? 'DirectML' : 'CUDA';\n            logger.info(`⚠️  ${gpuType} not available, falling back to CPU...`);\n          }\n          // Continue to next device in list\n          if (device === devicesToTry[devicesToTry.length - 1]) {\n            throw deviceError; // Last device failed, propagate error\n          }\n        }\n      }\n\n      throw new Error('No suitable device found for embedding model');\n    } catch (error) {\n      isInitializing = false;\n      initPromise = null;\n      embedderInstance = null;\n      throw error;\n    } finally {\n      isInitializing = false;\n    }\n  })();\n\n  return initPromise;\n};\n\n/**\n * Check if the embedder is initialized and ready\n */\nexport const isEmbedderReady = (): boolean => {\n  return isHttpMode() || embedderInstance !== null;","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/embeddings/embedder.ts#L234-L270","documentation":"Thrown by initEmbedder() after the device-probe for-loop completes without returning. Logically this is a defensive safety net: when devicesToTry is non-empty, the last device's error is already rethrown at line 247, and network errors rethrow at line 239 — so reaching this line means the loop body neither returned nor threw on any device, which should not happen with the current device list construction. It exists to convert a silent fall-through into an explicit failure rather than returning undefined.","triggerScenarios":"Effectively unreachable under normal control flow — the loop always either returns embedderInstance on success or throws (network error, or last-device error). Could surface only if a future change to devicesToTry produced an empty list, or if a device attempt resolved without setting embedderInstance and without throwing.","commonSituations":"Not expected in practice; if observed, indicates a logic regression in device-list construction or a transformers.js pipeline() that returned a falsy value without throwing.","solutions":["Retry the analyze — if transient, the device probe may succeed next time.","Set GITNEXUS_EMBEDDING_DEVICE=cpu explicitly to collapse the device list to a single deterministic attempt.","If it reproduces, file a GitNexus issue with the GitNexus version, OS/arch, and device config — this path is not expected to be reachable.","Switch to HTTP mode (GITNEXUS_EMBEDDING_URL) to bypass the local device probe entirely."],"exampleFix":"# before — auto device selection reaches an unexpected fall-through\n$ npx gitnexus analyze --embeddings\n# after — pin to cpu to make the device list deterministic\n$ GITNEXUS_EMBEDDING_DEVICE=cpu npx gitnexus analyze --embeddings","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await initEmbedder();\n} catch (err) {\n  if (err instanceof Error && err.message === 'No suitable device found for embedding model') {\n    // Pin a device and retry; if it reproduces, report it — this path is defensive.\n    process.env.GITNEXUS_EMBEDDING_DEVICE = 'cpu';\n    await initEmbedder();\n  } else throw err;\n}","preventionTips":["Set GITNEXUS_EMBEDDING_DEVICE=cpu to collapse the device list to one deterministic attempt.","Use HTTP mode to bypass the local device probe entirely.","Report a reproducer if you hit this — it indicates a logic regression."],"tags":["embeddings","device-probe","defensive","unreachable"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}