{"record":{"id":"e0e67d808777de1f","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"module-mod-module-param-param-param-name-e0e67d","errorCode":null,"errorMessage":"Module '${mod.module}', param '${param.param_name}': allowed_scopes must be non-empty array","messagePattern":"Module '(.+?)', param '(.+?)': allowed_scopes must be non-empty array","errorType":"validation","errorClass":"ParamRegistryError","httpStatus":null,"severity":"error","filePath":"MemoryCore/src/metadata/config/param-registry.ts","lineNumber":136,"sourceCode":"        );\n      }\n      seenParams.add(param.param_name);\n\n      if (param.param_value === undefined || param.param_value === null) {\n        throw new ParamRegistryError(\n          `Module '${mod.module}', param '${param.param_name}': param_value is required`,\n        );\n      }\n      if (!param.description) {\n        throw new ParamRegistryError(\n          `Module '${mod.module}', param '${param.param_name}': description is required`,\n        );\n      }\n      if (\n        !Array.isArray(param.allowed_scopes) ||\n        param.allowed_scopes.length === 0\n      ) {\n        throw new ParamRegistryError(\n          `Module '${mod.module}', param '${param.param_name}': allowed_scopes must be non-empty array`,\n        );\n      }\n      for (const scope of param.allowed_scopes) {\n        if (scope !== \"global\" && scope !== \"user\") {\n          throw new ParamRegistryError(\n            `Module '${mod.module}', param '${param.param_name}': invalid scope '${scope}'`,\n          );\n        }\n      }\n    }\n\n    registry.set(mod.module, mod);\n  }\n\n  return registry;\n}\n","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/metadata/config/param-registry.ts#L118-L154","documentation":"Each param must declare an allowed_scopes array containing at least one scope. buildRegistry throws this when allowed_scopes is missing, not an array, or an empty array. Scopes control where the parameter may be applied (later entries must be 'global' or 'user').","triggerScenarios":"A param in data.modules[i].params has allowed_scopes absent, set to a non-array (e.g. a string), or set to [] when loadParamRegistry validates it.","commonSituations":"New params authored before deciding on scoping; a tool serializing a single scope as a bare string instead of an array; an edit that emptied the array.","solutions":["Set allowed_scopes to an array containing \"global\", \"user\", or both","If the scope value is a string, wrap it: [\"global\"] instead of \"global\"","Choose the correct scope(s) for the param's intended visibility and set them","Validate with a schema requiring array + minItems: 1 on allowed_scopes before loading"],"exampleFix":"// before\n{ \"param_name\": \"max_entries\", \"param_value\": 1000, \"description\": \"...\", \"allowed_scopes\": [] }\n// after\n{ \"param_name\": \"max_entries\", \"param_value\": 1000, \"description\": \"...\", \"allowed_scopes\": [\"global\"] }","handlingStrategy":"validation","validationCode":"for (const m of data.modules) {\n  for (const p of m.params ?? []) {\n    const s = p.allowed_scopes;\n    if (!Array.isArray(s) || s.length === 0) {\n      throw new Error(`${m.module}.${p.param_name} needs a non-empty allowed_scopes array`);\n    }\n    if (!s.every(x => x === 'global' || x === 'user')) {\n      throw new Error(`${m.module}.${p.param_name} has invalid scopes`);\n    }\n  }\n}","typeGuard":"function hasValidScopes(p) {\n  return Array.isArray(p?.allowed_scopes) && p.allowed_scopes.length > 0\n    && p.allowed_scopes.every(s => s === 'global' || s === 'user');\n}","tryCatchPattern":"try {\n  const registry = await loadParamRegistry();\n} catch (e) {\n  if (e instanceof ParamRegistryError && e.message.includes('allowed_scopes')) {\n    console.error('Set allowed_scopes to [\"global\"], [\"user\"], or both:', e.message);\n  } else throw e;\n}","preventionTips":["Always wrap a single scope in an array: [\"global\"] not \"global\"","Decide the scope for each param at authoring time","Validate allowed_scopes against the enum ['global','user'] 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"}