{"record":{"id":"ac74a6c7cefe4fe7","repo":"abhigyanpatwari/GitNexus","slug":"embedding-device-must-be-one-of-auto-dml-cuda-c","errorCode":null,"errorMessage":"embedding device must be one of auto, dml, cuda, cpu, wasm; got \"${value}\"","messagePattern":"embedding device must be one of auto, dml, cuda, cpu, wasm; got \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/config.ts","lineNumber":71,"sourceCode":"  const parsed = Number(value);\n  if (!Number.isInteger(parsed) || parsed <= 0) {\n    throw new Error(`${name} must be a positive integer, got \"${value}\"`);\n  }\n  return parsed;\n};\n\nconst parseDevice = (value: string | undefined): EmbeddingConfig['device'] | undefined => {\n  if (value === undefined) return undefined;\n  if (\n    value === 'auto' ||\n    value === 'dml' ||\n    value === 'cuda' ||\n    value === 'cpu' ||\n    value === 'wasm'\n  ) {\n    return value;\n  }\n  throw new Error(`embedding device must be one of auto, dml, cuda, cpu, wasm; got \"${value}\"`);\n};\n\nexport const resolveEmbeddingConfig = (\n  overrides: Partial<EmbeddingConfig> = {},\n): EmbeddingConfig => {\n  const env = process.env;\n  return {\n    ...DEFAULT_EMBEDDING_CONFIG,\n    ...overrides,\n    batchSize: parsePositiveInt(\n      'GITNEXUS_EMBEDDING_BATCH_SIZE',\n      env.GITNEXUS_EMBEDDING_BATCH_SIZE,\n      overrides.batchSize ?? DEFAULT_EMBEDDING_CONFIG.batchSize,\n    ),\n    subBatchSize: parsePositiveInt(\n      'GITNEXUS_EMBEDDING_SUB_BATCH_SIZE',\n      env.GITNEXUS_EMBEDDING_SUB_BATCH_SIZE,\n      overrides.subBatchSize ?? DEFAULT_EMBEDDING_CONFIG.subBatchSize,","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/core/embeddings/config.ts#L53-L89","documentation":"GITNEXUS_EMBEDDING_DEVICE must be one of the enumerated execution backends — auto, dml (Windows DirectML), cuda (NVIDIA), cpu, or wasm. parseDevice() rejects every other spelling with this error. The allow-list exists because the value is passed straight to transformers.js/ONNX session options, and a silently passed typo would surface later as an opaque ONNX failure.","triggerScenarios":"Setting GITNEXUS_EMBEDDING_DEVICE to anything outside {auto,dml,cuda,cpu,wasm} — e.g. 'gpu', 'metal', 'CUDA' (uppercase), 'CUDA:1', 'rocm' — then initializing local embeddings (getOrCreateEmbedder / analyze --embeddings without an HTTP URL).","commonSituations":"Users guessing device names from other ML tools ('metal' on macOS, 'gpu'), uppercase spellings copied from docs of other frameworks, or trailing whitespace/quotes surviving from .env files.","solutions":["Use exactly one of the five values, lowercase: export GITNEXUS_EMBEDDING_DEVICE=cuda.","Use auto to let the runtime pick the best available backend.","Trim stray whitespace/quotes from .env values (value.trim() is not applied here).","For Apple Silicon, prefer auto — the wasm/cpu path is chosen appropriately; there is no 'metal' option."],"exampleFix":"# before\nexport GITNEXUS_EMBEDDING_DEVICE=gpu\nnpx gitnexus analyze --embeddings\n# embedding device must be one of auto, dml, cuda, cpu, wasm; got \"gpu\"\n\n# after\nexport GITNEXUS_EMBEDDING_DEVICE=auto\nnpx gitnexus analyze --embeddings","handlingStrategy":"validation","validationCode":"const EMBEDDING_DEVICES = new Set(['auto', 'dml', 'cuda', 'cpu', 'wasm']);\nfunction embeddingDeviceValid(v: string | undefined): boolean {\n  return v === undefined || EMBEDDING_DEVICES.has(v);\n}\nif (!embeddingDeviceValid(process.env.GITNEXUS_EMBEDDING_DEVICE)) {\n  throw new Error(`GITNEXUS_EMBEDDING_DEVICE must be one of: ${[...EMBEDDING_DEVICES].join(', ')}`);\n}","typeGuard":"function isEmbeddingDevice(v: unknown): v is 'auto' | 'dml' | 'cuda' | 'cpu' | 'wasm' {\n  return typeof v === 'string' && ['auto', 'dml', 'cuda', 'cpu', 'wasm'].includes(v);\n}","tryCatchPattern":"try {\n  await runWithEmbeddings();\n} catch (err) {\n  if (String((err as Error).message).includes('embedding device must be one of')) {\n    process.env.GITNEXUS_EMBEDDING_DEVICE = 'auto';\n    return runWithEmbeddings();\n  }\n  throw err;\n}","preventionTips":["Use lowercase spellings exactly; there is no 'metal', 'gpu', or 'rocm' option.","Prefer auto unless you specifically need to force a backend.","Trim whitespace and strip quotes when generating .env values.","Remember dml is Windows-only and cuda is NVIDIA-only."],"tags":["embeddings","environment-variable","config-validation","device-selection"],"backgroundTag":"invalid-env-var-value","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}