{"record":{"id":"12a3b8364789a5ea","repo":"koala73/worldmonitor","slug":"input-too-large","errorCode":"INPUT_TOO_LARGE","errorMessage":"INPUT_TOO_LARGE","messagePattern":"INPUT_TOO_LARGE","errorType":"validation","errorClass":"ConvexError","httpStatus":null,"severity":"error","filePath":"convex/followedCountries.ts","lineNumber":502,"sourceCode":" * downgrade is a separate concern handled by NOT auto-deleting on\n * downgrade; merge is the FIRST sign-in and has no PRO history to\n * grandfather.)\n */\nexport const mergeAnonymousLocal = mutation({\n  args: { countries: v.array(v.string()) },\n  handler: async (ctx, args): Promise<MergeAnonymousLocalResult> => {\n    const identity = await ctx.auth.getUserIdentity();\n    if (!identity) throw new ConvexError({ kind: \"UNAUTHENTICATED\" });\n    const userId = identity.subject;\n\n    // Step 2: empty-input guard.\n    if (args.countries.length === 0) {\n      throw new ConvexError({ kind: \"EMPTY_INPUT\" });\n    }\n\n    // Step 3: defensive upper-bound on input length.\n    if (args.countries.length > MAX_MERGE_INPUT) {\n      throw new ConvexError({\n        kind: \"INPUT_TOO_LARGE\",\n        max: MAX_MERGE_INPUT,\n        received: args.countries.length,\n      });\n    }\n\n    // Step 4: ISO-2 registry filter; collect droppedInvalid in input order.\n    const droppedInvalid: string[] = [];\n    const validInputs: string[] = [];\n    for (const code of args.countries) {\n      if (isValidIso2(code)) {\n        validInputs.push(code);\n      } else {\n        droppedInvalid.push(code);\n      }\n    }\n\n    // Step 5: canonicalize — dedupe in first-seen order. Without this, a","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/convex/followedCountries.ts#L484-L520","documentation":"Guard in mergeAnonymousLocal: args.countries exceeds the maximum allowed merge batch size (INPUT_TOO_LARGE kind). The cap backs the server-side free-user limit — a merge must never be able to balloon a free account past the follow cap in one call.","triggerScenarios":"Thrown at convex/followedCountries.ts:502 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Chunk the local countries list into batches within the limit and merge sequentially","Cap anonymous local storage client-side so it can never exceed the merge limit"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}