{"record":{"id":"bf56423d1fb4251d","repo":"TencentCloud/TencentDB-Agent-Memory","slug":"invalid-param-value","errorCode":"invalid_param_value","errorMessage":"param ${module}.${paramName} value '${str}' is not a valid integer","messagePattern":"param (.+?)\\.(.+?) value '(.+?)' is not a valid integer","errorType":"error_code","errorClass":"MetadataError","httpStatus":null,"severity":"error","filePath":"MemoryCore/src/metadata/service/config-param-service.ts","lineNumber":140,"sourceCode":"    const cached = this.getCached(cacheKey);\n    if (cached !== undefined) return cached;\n\n    const userRow = await this.store.getConfigParam(\"user\", userId, module, paramName);\n    if (userRow) {\n      this.setCache(cacheKey, userRow.param_value);\n      return userRow.param_value;\n    }\n\n    const globalValue = await this.getGlobalValue(module, paramName, paramDef);\n    this.setCache(cacheKey, globalValue);\n    return globalValue;\n  }\n\n  async getEffectiveInt(module: string, paramName: string, userId?: string): Promise<number> {\n    const str = await this.getEffectiveParam(module, paramName, userId);\n    const num = parseInt(str, 10);\n    if (Number.isNaN(num)) {\n      throw new MetadataError(\"invalid_param_value\", `param ${module}.${paramName} value '${str}' is not a valid integer`);\n    }\n    return num;\n  }\n\n  // ── 用户写入 ──\n\n  async setUserParam(userId: string, module: string, paramName: string, value: string): Promise<ConfigParamEntity> {\n    const moduleDef = getModuleDef(this.registry, module);\n    if (!moduleDef) {\n      throw new MetadataError(\"unknown_module\", `unknown module: ${module}`);\n    }\n\n    const paramDef = getParamDef(this.registry, module, paramName);\n    if (!paramDef) {\n      throw new MetadataError(\"invalid_param_key\", `unknown param: ${module}.${paramName}`);\n    }\n\n    if (!isUserWritable(this.registry, module, paramName)) {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/TencentCloud/TencentDB-Agent-Memory/blob/3efcd317b84146d6a08518ac0f7ee7c8a8d200ec/MemoryCore/src/metadata/service/config-param-service.ts#L122-L158","documentation":"getEffectiveInt resolves a config parameter to its effective string value and then parses it as an integer with parseInt. When the resolved value cannot be parsed as an integer (parseInt returns NaN), the service throws this invalid_param_value MetadataError. This guards numeric parameters like maxUsers and maxTeams from receiving non-numeric stored values.","triggerScenarios":"Calling getEffectiveInt (directly or via maxUsers/maxTeams helpers) for a parameter whose effective string value is empty, non-numeric (e.g. 'abc', 'true'), or contains a non-numeric prefix such that parseInt yields NaN.","commonSituations":"A config parameter was seeded or overridden in the store with a typo'd value ('10oo'), a placeholder ('unset'), or an empty string; or a caller stored a numeric param via setUserParam with an invalid literal that was never validated.","solutions":["Check the stored/effective value of the parameter (global default or user override) and correct it to a valid integer string, e.g. '100'.","Re-seed the parameter definition so it has a sane numeric default instead of an empty/placeholder value.","If the value may legitimately be non-numeric, use getEffectiveParam instead and parse/validate it yourself.","Wrap the call in try-catch on MetadataError with code 'invalid_param_value' and fall back to a numeric default."],"exampleFix":"// before\nconst max = await configService.getEffectiveInt(\"memory\", \"maxItems\");\n// after — validate/fallback\nlet max = 100;\ntry {\n  max = await configService.getEffectiveInt(\"memory\", \"maxItems\");\n} catch (e) {\n  if ((e as MetadataError).code !== \"invalid_param_value\") throw e;\n}","handlingStrategy":"try-catch","validationCode":"const raw = await svc.getEffectiveParam(module, paramName, userId);\nif (raw === \"\" || !Number.isInteger(parseInt(raw, 10))) throw new Error(`expected integer for ${module}.${paramName}, got '${raw}'`);","typeGuard":"function isIntString(s: string): boolean {\n  return /^-?\\d+$/.test(s.trim());\n}","tryCatchPattern":"try {\n  max = await svc.getEffectiveInt(module, paramName, userId);\n} catch (e) {\n  if (e instanceof MetadataError && e.code === \"invalid_param_value\") {\n    max = 100; // sensible default\n  } else throw e;\n}","preventionTips":["Seed every integer param with a valid numeric default in the registry.","Validate stored values at write time so non-numeric values never enter the store.","Prefer getEffectiveParam plus your own parsing when values may be unset.","Monitor for invalid_param_value in logs to catch corrupted config data early."],"tags":["config","validation","integer-parsing"],"backgroundTag":"invalid-argument-value","analyzedSha":"3efcd317b84146d6a08518ac0f7ee7c8a8d200ec","analyzedAt":"2026-09-01T05:44:22.276Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}