{"record":{"id":"02396809bb831d35","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"module-mod-module-must-have-at-least-one-para","errorCode":null,"errorMessage":"Module '${mod.module}' must have at least one param","messagePattern":"Module '(.+?)' must have at least one param","errorType":"validation","errorClass":"ParamRegistryError","httpStatus":null,"severity":"error","filePath":"MemoryCore/src/metadata/config/param-registry.ts","lineNumber":100,"sourceCode":"  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)) {\n        throw new ParamRegistryError(\n          `Module '${mod.module}': invalid param_name '${param.param_name}': must match ${PARAM_NAME_RE}`,\n        );\n      }\n      if (seenParams.has(param.param_name)) {\n        throw new ParamRegistryError(\n          `Module '${mod.module}': duplicate param_name '${param.param_name}'`,\n        );","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/metadata/config/param-registry.ts#L82-L118","documentation":"A module entry must declare at least one parameter: buildRegistry throws this when mod.params is not an array or is empty. An empty module would be meaningless in the registry, so the library refuses to load it.","triggerScenarios":"loadParamRegistry sees data.modules[i].params missing, set to null, set to a non-array, or an empty array [].","commonSituations":"Creating a placeholder module before adding params; a script that strips params during a transform; typos like \"param\" instead of \"params\" in the JSON.","solutions":["Add at least one param object to the module's params array","If the module has no params yet, remove the module entry until it does","Fix the field name/key typo if params was accidentally renamed","Validate the registry file with a schema enforcing minItems: 1 on params"],"exampleFix":"// before\n{ \"module\": \"cache\", \"description\": \"...\", \"params\": [] }\n// after\n{ \"module\": \"cache\", \"description\": \"...\", \"params\": [ { \"param_name\": \"max_entries\", \"param_value\": 1000, \"description\": \"Max cache entries\", \"allowed_scopes\": [\"global\"] } ] }","handlingStrategy":"validation","validationCode":"for (const m of data.modules) {\n  if (!Array.isArray(m.params) || m.params.length === 0) {\n    throw new Error(`module ${m.module} must define at least one param`);\n  }\n}","typeGuard":"function hasParams(mod) {\n  return Array.isArray(mod.params) && mod.params.length > 0;\n}","tryCatchPattern":"try {\n  const registry = await loadParamRegistry();\n} catch (e) {\n  if (e instanceof ParamRegistryError && e.message.includes('must have at least one param')) {\n    console.error('Add params or remove the empty module entry:', e.message);\n  } else throw e;\n}","preventionTips":["Do not create placeholder modules; add the module only when params exist","Ensure transforms/scripts never emit an empty params array","Validate params as a non-empty array in CI"],"tags":["configuration","validation","empty-collection"],"backgroundTag":"schema-validation-failed","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}