{"record":{"id":"b550430bf06faeff","repo":"nocodb/nocodb","slug":"invalid-arg","errorCode":"INVALID_ARG","errorMessage":"The REPEAT function requires a numeric as the parameter at position 2","messagePattern":"The REPEAT function requires a numeric as the parameter at position 2","errorType":"validation","errorClass":"FormulaError","httpStatus":null,"severity":"error","filePath":"packages/nocodb-sdk/src/lib/formula/formulas.ts","lineNumber":505,"sourceCode":"        type: FormulaDataTypes.NUMERIC,\n      },\n    },\n    description:\n      'Calculate the remainder resulting from integer division of input parameters.',\n    syntax: 'MOD(value1, value2)',\n    examples: ['MOD(1024, 1000) => 24', 'MOD({column}, 2)'],\n    returnType: FormulaDataTypes.NUMERIC,\n  },\n  REPEAT: {\n    docsUrl: `${API_DOC_PREFIX}/field-types/formula/string-functions#repeat`,\n\n    validation: {\n      args: {\n        rqd: 2,\n      },\n      custom(argTypes: FormulaDataTypes[], parsedTree) {\n        if (argTypes[1] !== FormulaDataTypes.NUMERIC) {\n          throw new FormulaError(\n            FormulaErrorType.INVALID_ARG,\n            {\n              key: 'msg.formula.typeIsExpected',\n              type: 'Numeric',\n              calleeName: parsedTree.callee?.name?.toUpperCase(),\n              position: 2,\n            },\n            'The REPEAT function requires a numeric as the parameter at position 2'\n          );\n        }\n      },\n    },\n    description:\n      'Concatenate the specified number of copies of the input parameter string.',\n    syntax: 'REPEAT(str, count)',\n    examples: ['REPEAT(\"A\", 5) => \"AAAAA\"', 'REPEAT({column}, 5)'],\n    returnType: FormulaDataTypes.STRING,\n  },","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/nocodb/nocodb/blob/d3caaf4e890acf64bd49b788cf6dc32b7644c895/packages/nocodb-sdk/src/lib/formula/formulas.ts#L487-L523","documentation":"Thrown by the REPEAT custom validator (formulas.ts:505) when the resolved type of the second argument (the repeat count) is not FormulaDataTypes.NUMERIC. Unlike the date checks this one inspects argTypes (the post-recursion resolved types), so it applies to BOTH literals and column references. REPEAT's declared args has no generic type, so the custom validator is the sole type gate.","triggerScenarios":"REPEAT(\"abc\", \"5\") where the count is a quoted string literal; REPEAT({Name}, {Label}) where {Label} is a text column; REPEAT({Name}, {Flag}) with a boolean column.","commonSituations":"Quoting the count because it came from a form input; pointing the second arg at a text or single-select column instead of a number; leftover placeholder string in a generated formula.","solutions":["Pass a numeric literal unquoted: REPEAT({Name}, 5).","Point the second argument at a Number column: REPEAT({Name}, {Count}).","If the value comes from a string column, wrap or convert it to a numeric expression first."],"exampleFix":"// before\nREPEAT({Name}, \"5\")\n// after\nREPEAT({Name}, 5)","handlingStrategy":"validation","validationCode":"// Before submitting, ensure the REPEAT count arg resolves to numeric.\n// If it is a literal, it must be a bare number.\nfunction assertRepeatCountNumeric(formula: string, numericColumnTitles: Set<string>) {\n  const m = formula.match(/REPEAT\\([^,]+,\\s*(\\{([^}]+)\\}|['\"]?[^)]*?['\"]?)\\s*\\)/i);\n  if (!m) return;\n  const tok = m[1].trim();\n  if (tok.startsWith('{')) {\n    if (!numericColumnTitles.has(m[2])) throw new Error('REPEAT count column is not numeric');\n  } else if (!/^\\d+(\\.\\d+)?$/.test(tok.replace(/^['\"]|['\"]$/g, ''))) {\n    throw new Error('REPEAT count must be a numeric literal (unquoted)');\n  }\n}","typeGuard":"function isRepeatNumericError(e: unknown): e is FormulaError {\n  return e instanceof FormulaError && e.type === FormulaErrorType.INVALID_ARG\n    && e.extra?.key === 'msg.formula.typeIsExpected' && e.extra?.position === 2\n    && e.extra?.calleeName === 'REPEAT';\n}","tryCatchPattern":"try {\n  await validateFormulaAndExtractTreeWithType({ formula, columns, clientOrSqlUi, getMeta });\n} catch (e) {\n  if (e instanceof FormulaError && e.type === FormulaErrorType.INVALID_ARG\n      && e.extra?.calleeName === 'REPEAT') {\n    // prompt: the repeat count must be numeric\n  }\n  throw e;\n}","preventionTips":["Never quote the REPEAT count; pass a bare number or a Number column.","Confirm the referenced count column is a Number type, not Text.","Validate in the editor before save."],"tags":["formula","numeric-arg","type-mismatch","invalid-arg"],"backgroundTag":null,"analyzedSha":"d3caaf4e890acf64bd49b788cf6dc32b7644c895","analyzedAt":"2026-08-12T13:07:32.092Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}