{"record":{"id":"26ae090d9332b876","repo":"transloadit/uppy","slug":"transloadit-the-params-option-is-a-malformed-js","errorCode":null,"errorMessage":"Transloadit: The `params` option is a malformed JSON string.","messagePattern":"Transloadit: The `params` option is a malformed JSON string\\.","errorType":"validation","errorClass":"ErrorWithCause","httpStatus":null,"severity":"error","filePath":"packages/@uppy/transloadit/src/index.ts","lineNumber":184,"sourceCode":"const sendErrorToConsole = (originalErr: Error) => (err: Error) => {\n  const error = new ErrorWithCause('Failed to send error to the client', {\n    cause: err,\n  })\n  console.error(error, originalErr)\n}\n\nfunction validateParams(params?: AssemblyOptions['params']): void {\n  if (params == null) {\n    throw new Error('Transloadit: The `params` option is required.')\n  }\n\n  let parsed: AssemblyParameters\n  if (typeof params === 'string') {\n    try {\n      parsed = JSON.parse(params) as AssemblyParameters\n    } catch (err) {\n      // Tell the user that this is not an Uppy bug!\n      throw new ErrorWithCause(\n        'Transloadit: The `params` option is a malformed JSON string.',\n        { cause: err },\n      )\n    }\n  } else {\n    parsed = params\n  }\n\n  if (!parsed.auth?.key) {\n    throw new Error(\n      'Transloadit: The `params.auth.key` option is required. ' +\n        'You can find your Transloadit API key at https://transloadit.com/c/template-credentials',\n    )\n  }\n}\n\nfunction ensureAssemblyId(status: AssemblyResponse): string {\n  if (!status.assembly_id) {","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/transloadit/uppy/blob/5d4dedd02a1ac0ae022c75c54aca76558f88e256/packages/@uppy/transloadit/src/index.ts#L166-L202","documentation":"Thrown when the Transloadit params option is supplied as a JSON string but JSON.parse fails. It wraps the parse error via ErrorWithCause (cause preserved), and the message stresses this is a user-input bug, not an Uppy/Transloadit bug. Validation happens in validateParams during upload preparation.","triggerScenarios":"Passing params as a string like \"{steps: ...}\" (unquoted keys), with trailing commas, smart quotes pasted from a doc, or truncated JSON; then calling uppy.upload().","commonSituations":"Copy-pasting Assembly instructions JSON from tutorials with typographic quotes; building the JSON via string concatenation that breaks escaping; a template engine or env var mangling quotes.","solutions":["Validate the string with JSON.parse at config-load time to fail early with the real parse error","Pass params as an object literal instead of a string — no parsing involved","Use a JSON linter/validator on the embedded string; watch for smart quotes and comments (not valid JSON)","If params come from an env var/endpoint, JSON.parse and log a clear config error before Uppy boots"],"exampleFix":"// before\nuppy.use(Transloadit, {\n  params: `{ \"auth\": {\"key\": \"...\"}, steps: {...} }`, // unquoted keys -> throw\n})\n\n// after\nuppy.use(Transloadit, {\n  params: {\n    auth: { key: process.env.TRANSLOADIT_KEY },\n    steps: { encode: { robot: '/video/encode', preset: 'ipad-high' } },\n  },\n})","handlingStrategy":"validation","validationCode":"const paramsString = process.env.TRANSLOADIT_PARAMS!\nconst parsed = JSON.parse(paramsString) // fail fast with the real parse error\nuppy.use(Transloadit, { params: parsed })","typeGuard":"null","tryCatchPattern":"try { JSON.parse(paramsString) } catch (err) {\n  console.error('Invalid Transloadit params JSON', err)\n  // fix config before calling uppy.upload()\n}","preventionTips":["Pass params as an object, not a string","Validate env-provided JSON at startup","Beware smart quotes when pasting JSON"],"tags":["transloadit","json","parse-error","config"],"backgroundTag":"invalid-json-config","analyzedSha":"5d4dedd02a1ac0ae022c75c54aca76558f88e256","analyzedAt":"2026-08-28T12:18:41.267Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}