{"record":{"id":"8e98f7a6d614478d","repo":"abhigyanpatwari/GitNexus","slug":"invalid-content-retention-env-raw-expected-one-of-full","errorCode":null,"errorMessage":"Invalid ${CONTENT_RETENTION_ENV} \"${raw}\". Expected one of: full, symbol, none.","messagePattern":"Invalid (.+?) \"(.+?)\"\\. Expected one of: full, symbol, none\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/content-retention.ts","lineNumber":17,"sourceCode":"import fs from 'node:fs/promises';\nimport type { KnowledgeGraph } from './graph/types.js';\nimport {\n  CONTENT_RETENTION_SCHEMA_VERSION,\n  type ContentRetention,\n  type FtsProfile,\n  type RepoMeta,\n} from '../storage/repo-meta.js';\n\nexport const CONTENT_RETENTION_ENV = 'GITNEXUS_CONTENT_RETENTION';\n\nexport const contentRetentionFromEnvironment = (): ContentRetention => {\n  const raw = process.env[CONTENT_RETENTION_ENV];\n  if (raw === undefined || raw.trim() === '') return 'full';\n  const value = raw.trim();\n  if (value === 'full' || value === 'symbol' || value === 'none') return value;\n  throw new Error(\n    `Invalid ${CONTENT_RETENTION_ENV} \"${raw}\". Expected one of: full, symbol, none.`,\n  );\n};\n\nexport const contentRetentionFromMeta = (\n  meta: Pick<RepoMeta, 'contentRetention'> | null | undefined,\n): ContentRetention => {\n  const retention = meta?.contentRetention;\n  if (retention === undefined || retention === 'full') return 'full';\n  if (retention === 'symbol' || retention === 'none') return retention;\n  // Legacy metadata has no field; an explicit unknown value is corrupt and must not expose text.\n  return 'none';\n};\n\nexport const ftsProfileForContentRetention = (retention: ContentRetention): FtsProfile => {\n  switch (retention) {\n    case 'symbol':\n      return 'symbol-no-file-content';","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/core/content-retention.ts#L1-L35","documentation":"Thrown by contentRetentionFromEnvironment when the GITNEXUS_CONTENT_RETENTION environment variable is set to a value other than 'full', 'symbol', or 'none'. The library validates the enum strictly at startup so an invalid retention mode never silently changes index storage behavior. Unset or empty values default to 'full'.","triggerScenarios":"Setting GITNEXUS_CONTENT_RETENTION to any string other than exactly 'full', 'symbol', or 'none' (e.g. 'Full', 'FULL', 'symbols', '1') and then initializing repo content-retention settings.","commonSituations":"Typo or casing mistakes in shell profiles / CI env config; copying a value like 'symbol ' with stray whitespace is fine (trimmed), but 'sybmol' is not; docs from older versions using different names.","solutions":["Set GITNEXUS_CONTENT_RETENTION to exactly one of: full, symbol, none (lowercase).","Unset the variable entirely to get the default 'full' retention.","Check your .env / CI secret / shell profile for the misspelled value."],"exampleFix":"// before (.env)\nGITNEXUS_CONTENT_RETENTION=Symbols\n// after (.env)\nGITNEXUS_CONTENT_RETENTION=symbol","handlingStrategy":"validation","validationCode":"const raw = process.env.GITNEXUS_CONTENT_RETENTION;\nif (raw !== undefined && !['full', 'symbol', 'none'].includes(raw.trim())) {\n  throw new Error(`GITNEXUS_CONTENT_RETENTION must be full|symbol|none, got \"${raw}\"`);\n}","typeGuard":"const isContentRetention = (v: unknown): v is 'full' | 'symbol' | 'none' =>\n  v === 'full' || v === 'symbol' || v === 'none';","tryCatchPattern":"try {\n  retention = contentRetentionFromEnvironment();\n} catch (err) {\n  console.error(err.message);\n  process.exitCode = 1;\n}","preventionTips":["Only use exact lowercase values: full, symbol, none","Validate the env var in CI config linting before deploy","Prefer unsetting the variable over guessing values — default is 'full'"],"tags":["configuration","environment","validation","enum"],"backgroundTag":"invalid-env-var-value","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}