TencentCloud/TencentDB-Agent-Memory · error · ParamRegistryError

Duplicate module '${mod.module}'

Error message

Duplicate module '${mod.module}'

What it means

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.

Source

Thrown at MemoryCore/src/metadata/config/param-registry.ts:92

export function buildRegistry(data: ConfigParamsFile): ConfigParamRegistry {
  if (!data.version || !Array.isArray(data.modules)) {
    throw new ParamRegistryError("Config params file must have 'version' and 'modules' array");
  }

  const registry: ConfigParamRegistry = new Map();
  const seenModules = new Set<string>();

  for (const mod of data.modules) {
    if (!mod.module || typeof mod.module !== "string") {
      throw new ParamRegistryError("Each module entry must have a 'module' string field");
    }
    if (!MODULE_RE.test(mod.module)) {
      throw new ParamRegistryError(
        `Invalid module name '${mod.module}': must match ${MODULE_RE}`,
      );
    }
    if (seenModules.has(mod.module)) {
      throw new ParamRegistryError(`Duplicate module '${mod.module}'`);
    }
    seenModules.add(mod.module);

    if (!mod.description) {
      throw new ParamRegistryError(`Module '${mod.module}' must have a description`);
    }
    if (!Array.isArray(mod.params) || mod.params.length === 0) {
      throw new ParamRegistryError(`Module '${mod.module}' must have at least one param`);
    }

    const seenParams = new Set<string>();
    for (const param of mod.params) {
      if (!param.param_name || typeof param.param_name !== "string") {
        throw new ParamRegistryError(
          `Module '${mod.module}': each param must have a 'param_name' string`,
        );
      }
      if (!PARAM_NAME_RE.test(param.param_name)) {

View on GitHub (pinned to 3efcd317b8)

Solutions

  1. Search the registry file for the duplicated module name and delete one of the entries
  2. If both entries are intentional, merge their params lists into a single module entry
  3. If the modules are genuinely different, rename one to a unique name matching MODULE_RE
  4. Add a uniqueness check in CI (e.g. jq or a script) that fails on duplicate module names

Example fix

// before
{ "modules": [ { "module": "cache", ... }, { "module": "cache", ... } ] }
// after
{ "modules": [ { "module": "cache", "params": [ /* merged params */ ] } ] }
Defensive patterns

Strategy: validation

Validate before calling

const names = data.modules.map(m => m.module);
const dupes = names.filter((n, i) => names.indexOf(n) !== i);
if (dupes.length) throw new Error(`duplicate modules: ${[...new Set(dupes)].join(', ')}`);

Try / catch

try {
  const registry = await loadParamRegistry();
} catch (e) {
  if (e instanceof ParamRegistryError && e.message.startsWith('Duplicate module')) {
    console.error('Deduplicate module entries in the registry file:', e.message);
  } else throw e;
}

Prevention

When it happens

Trigger: loadParamRegistry encounters a second entry in data.modules whose module string is already present in seenModules.

Common situations: 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.

Related errors


AI-assisted analysis of TencentCloud/TencentDB-Agent-Memory@3efcd317b8 (2026-09-01). Data as JSON: /api/errors/13275f709709a880. Report an issue: GitHub.