{"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":"validation","errorClass":"Error","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/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/embeddings/config.ts#L53-L89","documentation":"Thrown by parseDevice() in config.ts when GITNEXUS_EMBEDDING_DEVICE is set to a value outside the closed set {auto, dml, cuda, cpu, wasm}. The device string is passed straight to transformers.js's pipeline() options.device, so an unrecognized value would either crash inside ONNX Runtime or silently be ignored. Validating up front gives an actionable error naming the allowed set instead of a downstream native crash.","triggerScenarios":"resolveEmbeddingConfig() calls parseDevice(env.GITNEXUS_EMBEDDING_DEVICE) at config.ts:96-99. Fires on typos like gpu, metal, cudaa, auto-detect, or case variants like CUDA (the check is case-sensitive lowercase).","commonSituations":"Typing gpu or metal (common mental models from other ML stacks); using uppercase CUDA/CPU from a CI YAML that uppercases env vars; a copy-paste of 'auto ' with a trailing space; setting 'wasm' on a platform that actually can't use it (this error fires before that downstream check).","solutions":["Set GITNEXUS_EMBEDDING_DEVICE to exactly one of auto, dml, cuda, cpu, or wasm (lowercase).","Prefer 'auto' — it probes for CUDA/DirectML and falls back to cpu.","Unset the variable to accept the default ('auto')."],"exampleFix":"// before\nexport GITNEXUS_EMBEDDING_DEVICE=gpu\n// after\nexport GITNEXUS_EMBEDDING_DEVICE=auto","handlingStrategy":"validation","validationCode":"const VALID_DEVICES = ['auto', 'dml', 'cuda', 'cpu', 'wasm'] as const;\nconst dev = process.env.GITNEXUS_EMBEDDING_DEVICE;\nif (dev !== undefined && !VALID_DEVICES.includes(dev as any)) {\n  throw new Error(`GITNEXUS_EMBEDDING_DEVICE=${dev} invalid; choose one of ${VALID_DEVICES.join(', ')}`);\n}","typeGuard":"const isEmbeddingDevice = (v: string): v is 'auto' | 'dml' | 'cuda' | 'cpu' | 'wasm' =>\n  ['auto', 'dml', 'cuda', 'cpu', 'wasm'].includes(v);","tryCatchPattern":null,"preventionTips":["Use lowercase device tokens (the check is case-sensitive).","Prefer 'auto' unless you have a specific device requirement.","Avoid gpu/metal — they are not in the supported set."],"tags":["config","env-var","embeddings","validation"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}