{"record":{"id":"d7df10555dfb5f01","repo":"abhigyanpatwari/GitNexus","slug":"source-must-be-true-false-or-a-non-negative-int","errorCode":null,"errorMessage":"${source} must be true/false or a non-negative integer (node cap; 0 disables the cap).","messagePattern":"(.+?) must be true/false or a non-negative integer \\(node cap; 0 disables the cap\\)\\.","errorType":"validation","errorClass":"GitNexusRcError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/cli/analyze-config.ts","lineNumber":302,"sourceCode":"        }\n        return String(value);\n      }\n      if (typeof value === 'string') {\n        const trimmed = value.trim();\n        if (!trimmed) {\n          throw new GitNexusRcError(`${source} must not be empty.`);\n        }\n        return trimmed;\n      }\n      throw new GitNexusRcError(`${source} must be a number or numeric string.`);\n    }\n    case 'embeddings': {\n      // Mirror `--embeddings [limit]`: boolean toggles, a non-negative integer\n      // sets the node cap (normalized to a string, as Commander would supply).\n      if (typeof value === 'boolean') return value;\n      if (typeof value === 'number') {\n        if (!Number.isInteger(value) || value < 0) {\n          throw new GitNexusRcError(\n            `${source} must be true/false or a non-negative integer (node cap; 0 disables the cap).`,\n          );\n        }\n        return String(value);\n      }\n      throw new GitNexusRcError(\n        `${source} must be a boolean or a non-negative integer (node cap; 0 disables the cap).`,\n      );\n    }\n    default:\n      // Exhaustive — kept for forward-compat if a new kind is added.\n      throw new GitNexusRcError(`${source}: unsupported config value kind.`);\n  }\n};\n\n/**\n * Normalize one level (flat top-level or the nested `analyze` block) into a\n * partial `AnalyzeOptions`. Rejects unknown keys and two aliases that configure","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/cli/analyze-config.ts#L284-L320","documentation":"The 'embeddings' option mirrors the CLI's `--embeddings [limit]`: true/false toggles it, and a non-negative integer caps embedding nodes (0 disables the cap). This variant fires on the number branch: the value is a JSON number but is fractional or negative.","triggerScenarios":"{\"embeddings\": 1.5} or {\"embeddings\": -1} in .gitnexusrc; Number.isInteger(value) is false or value < 0 at analyze-config.ts:312.","commonSituations":"Trying to express a ratio or 'all' as a number; typos like -1 meaning 'unlimited'; float division results pasted from a calculator or script.","solutions":["Use true to enable with defaults, or a whole number cap: {\"embeddings\": 5000} (0 means no cap)","For fractional intent, round to the nearest integer node cap","Remember the normalized string is range-checked downstream — keep the cap within the flag's documented bounds"],"exampleFix":"// before (.gitnexusrc)\n{\"embeddings\": 1.5}\n// after\n{\"embeddings\": true}","handlingStrategy":"validation","validationCode":"const emb = rc.embeddings;\nif (typeof emb === 'number' && (!Number.isInteger(emb) || emb < 0)) {\n  throw new Error('embeddings must be true/false or a non-negative integer');\n}","typeGuard":"const isEmbeddingsValue = (v: unknown): v is boolean | number =>\n  typeof v === 'boolean' || (typeof v === 'number' && Number.isInteger(v) && v >= 0);","tryCatchPattern":"catch (err) {\n  if (err instanceof GitNexusRcError && err.message.includes('non-negative integer')) {\n    // round the cap or use a boolean toggle\n  }\n}","preventionTips":["Remember the semantics: boolean = toggle, integer = node cap, 0 = uncapped","Never put ratios or negatives in embeddings"],"tags":["config","validation","embeddings","gitnexusrc"],"backgroundTag":"config-type-mismatch","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}