{"record":{"id":"13275f709709a880","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"duplicate-module-mod-module","errorCode":null,"errorMessage":"Duplicate module '${mod.module}'","messagePattern":"Duplicate module '(.+?)'","errorType":"validation","errorClass":"ParamRegistryError","httpStatus":null,"severity":"error","filePath":"MemoryCore/src/metadata/config/param-registry.ts","lineNumber":92,"sourceCode":"export function buildRegistry(data: ConfigParamsFile): ConfigParamRegistry {\n  if (!data.version || !Array.isArray(data.modules)) {\n    throw new ParamRegistryError(\"Config params file must have 'version' and 'modules' array\");\n  }\n\n  const registry: ConfigParamRegistry = new Map();\n  const seenModules = new Set<string>();\n\n  for (const mod of data.modules) {\n    if (!mod.module || typeof mod.module !== \"string\") {\n      throw new ParamRegistryError(\"Each module entry must have a 'module' string field\");\n    }\n    if (!MODULE_RE.test(mod.module)) {\n      throw new ParamRegistryError(\n        `Invalid module name '${mod.module}': must match ${MODULE_RE}`,\n      );\n    }\n    if (seenModules.has(mod.module)) {\n      throw new ParamRegistryError(`Duplicate module '${mod.module}'`);\n    }\n    seenModules.add(mod.module);\n\n    if (!mod.description) {\n      throw new ParamRegistryError(`Module '${mod.module}' must have a description`);\n    }\n    if (!Array.isArray(mod.params) || mod.params.length === 0) {\n      throw new ParamRegistryError(`Module '${mod.module}' must have at least one param`);\n    }\n\n    const seenParams = new Set<string>();\n    for (const param of mod.params) {\n      if (!param.param_name || typeof param.param_name !== \"string\") {\n        throw new ParamRegistryError(\n          `Module '${mod.module}': each param must have a 'param_name' string`,\n        );\n      }\n      if (!PARAM_NAME_RE.test(param.param_name)) {","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/metadata/config/param-registry.ts#L74-L110","documentation":"buildRegistry throws this when two module entries in the registry file share the same 'module' name. The registry uses module names as unique keys (tracked in seenModules), so duplicates would create ambiguous parameter ownership. Loading fails until the duplicate is removed or renamed.","triggerScenarios":"loadParamRegistry encounters a second entry in data.modules whose module string is already present in seenModules.","commonSituations":"Merging registry files from two branches without deduplication; copy-pasting a module block and forgetting to rename it; automated tooling appending entries that already exist.","solutions":["Search the registry file for the duplicated module name and delete one of the entries","If both entries are intentional, merge their params lists into a single module entry","If the modules are genuinely different, rename one to a unique name matching MODULE_RE","Add a uniqueness check in CI (e.g. jq or a script) that fails on duplicate module names"],"exampleFix":"// before\n{ \"modules\": [ { \"module\": \"cache\", ... }, { \"module\": \"cache\", ... } ] }\n// after\n{ \"modules\": [ { \"module\": \"cache\", \"params\": [ /* merged params */ ] } ] }","handlingStrategy":"validation","validationCode":"const names = data.modules.map(m => m.module);\nconst dupes = names.filter((n, i) => names.indexOf(n) !== i);\nif (dupes.length) throw new Error(`duplicate modules: ${[...new Set(dupes)].join(', ')}`);","typeGuard":null,"tryCatchPattern":"try {\n  const registry = await loadParamRegistry();\n} catch (e) {\n  if (e instanceof ParamRegistryError && e.message.startsWith('Duplicate module')) {\n    console.error('Deduplicate module entries in the registry file:', e.message);\n  } else throw e;\n}","preventionTips":["Keep one canonical registry file per module; never append entries blindly during merges","Deduplicate by module name when merging branches","Use jq/CI script to assert module name uniqueness","Review generated registry diffs for repeated blocks"],"tags":["configuration","validation","duplicate"],"backgroundTag":"duplicate-key","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}