{"record":{"id":"7ab3a87aac0939c9","repo":"payloadcms/payload","slug":"argument-stripeargs-must-be-an-array","errorCode":null,"errorMessage":"Argument 'stripeArgs' must be an array.","messagePattern":"Argument 'stripeArgs' must be an array\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/plugin-stripe/src/utilities/stripeProxy.ts","lineNumber":37,"sourceCode":"    // NOTE: Stripe API methods using reference \"this\" within their functions, so we need to bind context\n    const foundMethod = lodashGet(stripe, stripeMethod).bind(contextToBind)\n\n    if (typeof foundMethod === 'function') {\n      if (Array.isArray(stripeArgs)) {\n        try {\n          const stripeResponse = await foundMethod(...stripeArgs)\n          return {\n            data: stripeResponse,\n            status: 200,\n          }\n        } catch (error: unknown) {\n          return {\n            message: `A Stripe API error has occurred: ${error}`,\n            status: 404,\n          }\n        }\n      } else {\n        throw new Error(`Argument 'stripeArgs' must be an array.`)\n      }\n    } else {\n      throw Error(\n        `The provided Stripe method of '${stripeMethod}' is not a part of the Stripe API.`,\n      )\n    }\n  } else {\n    throw Error('You must provide a Stripe method to call.')\n  }\n}\n","sourceCodeStart":19,"sourceCodeEnd":48,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/plugin-stripe/src/utilities/stripeProxy.ts#L19-L48","documentation":"Thrown by `stripeProxy` when `stripeMethod` resolves to a valid callable Stripe method but `stripeArgs` is not an array — the proxy spreads `foundMethod(...stripeArgs)`, so a non-array cannot be applied. This is a client payload-shape error, not a Stripe API error.","triggerScenarios":"POSTing to the Stripe REST endpoint with `stripeArgs` as an object (e.g. `{ limit: 10 }`) instead of an array (`[{ limit: 10 }]`); omitting `stripeArgs` so it is `undefined`; passing a JSON string instead of a parsed array.","commonSituations":"Misreading the example in `rest.ts` (`['cus_...']` or `[{ limit: 100 }, {...}]`) and sending a bare object; client serializer that wraps the value; copy-paste from a Stripe SDK call that takes positional args flattened to an object.","solutions":["Send `stripeArgs` as an array of positional arguments, e.g. `[{ limit: 100 }]` or `['cus_X']`","If calling a method that takes an ID plus params, use `['cus_X', { metadata: {...} }]`","Validate `Array.isArray(body.stripeArgs)` client-side before sending"],"exampleFix":"// before\n{ stripeMethod: 'customers.list', stripeArgs: { limit: 10 } }\n// after\n{ stripeMethod: 'customers.list', stripeArgs: [{ limit: 10 }] }","handlingStrategy":"validation","validationCode":"// Enforce the stripeArgs shape before sending\nconst body = { stripeMethod, stripeArgs }\nif (!Array.isArray(body.stripeArgs))\n  throw new Error('stripeArgs must be an array of positional args, e.g. [{ limit: 10 }]')\nawait fetch('/api/stripe', { method: 'POST', body: JSON.stringify(body) })","typeGuard":"function isValidStripePayload(p: unknown): p is { stripeMethod: string; stripeArgs: unknown[] } {\n  return !!p && typeof (p as any).stripeMethod === 'string' && Array.isArray((p as any).stripeArgs)\n}","tryCatchPattern":null,"preventionTips":["Always send `stripeArgs` as a positional-args array, not an object","For methods taking an ID plus options, use `[id, optionsObj]`","Add a client-side type check so the error never reaches the server"],"tags":["stripe","rest","validation","api-contract"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}