{"record":{"id":"9fc82b567b69d18a","repo":"different-ai/openwork","slug":"invalid-payload-9fc82b","errorCode":"invalid_payload","errorMessage":"providers must be an array of non-empty strings","messagePattern":"providers must be an array of non-empty strings","errorType":"http","errorClass":"ApiError","httpStatus":400,"severity":"error","filePath":"apps/server/src/server.ts","lineNumber":286,"sourceCode":"}\n\nfunction runtimeConfigKeys(config: RuntimeOpencodeConfig): string[] {\n  const keys: string[] = [];\n  if (config.default_agent) keys.push(\"default_agent\");\n  if (Array.isArray(config.plugin) && config.plugin.length) keys.push(\"plugin\");\n  if (Array.isArray(config.disabled_providers) && config.disabled_providers.length) keys.push(\"disabled_providers\");\n  if (isRecord(config.mcp) && Object.keys(config.mcp).length) keys.push(\"mcp\");\n  const permission = isRecord(config.permission) ? config.permission : null;\n  if (permission && isRecord(permission.external_directory) && Object.keys(permission.external_directory).length) {\n    keys.push(\"permission\");\n  }\n  if (isRecord(config.provider) && Object.keys(config.provider).length) keys.push(\"provider\");\n  return keys;\n}\n\nfunction parseDisabledProvidersPayload(value: unknown): string[] {\n  if (!Array.isArray(value)) {\n    throw new ApiError(400, \"invalid_payload\", \"providers must be an array of non-empty strings\");\n  }\n  const providers: string[] = [];\n  for (const entry of value) {\n    if (typeof entry !== \"string\" || !entry.trim()) {\n      throw new ApiError(400, \"invalid_payload\", \"providers must be an array of non-empty strings\");\n    }\n    const provider = entry.trim();\n    if (!providers.includes(provider)) providers.push(provider);\n  }\n  return providers;\n}\n\nfunction parseRuntimeProviderPatchPayload(body: Record<string, unknown>): Record<string, unknown> {\n  const provider = body.provider;\n  if (!isRecord(provider)) {\n    throw new ApiError(400, \"invalid_payload\", \"provider must be an object\");\n  }\n  for (const [providerId, value] of Object.entries(provider)) {","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/server/src/server.ts#L268-L304","documentation":"This 400 invalid_payload error is thrown by parseDisabledProvidersPayload when the request body is not a JSON array. The disabled-providers update endpoint expects an array of provider name strings, so any other top-level shape (object, string, null, missing body) is rejected before any validation of elements occurs.","triggerScenarios":"Calling the disabled-providers PATCH/PUT endpoint with body that is not an array, e.g. {\"providers\": [\"anthropic\"]} instead of [\"anthropic\"], or an empty/absent body.","commonSituations":"Wrapping the list in an object by mistake; sending form-encoded or stringified JSON with wrong Content-Type; older clients using a different payload shape.","solutions":["Send a raw JSON array as the body: [\"anthropic\", \"openai\"]","Ensure Content-Type: application/json and JSON.stringify the array","Check API docs for the exact endpoint payload shape"],"exampleFix":"// before\nawait fetch(url, { body: JSON.stringify({ providers: [\"anthropic\"] }) });\n// after\nawait fetch(url, { body: JSON.stringify([\"anthropic\"]), headers: { \"Content-Type\": \"application/json\" } });","handlingStrategy":"validation","validationCode":"if (!Array.isArray(providers)) throw new Error(\"providers must be a JSON array\");","typeGuard":"const isStringArray = (v: unknown): v is string[] => Array.isArray(v) && v.every(x => typeof x === \"string\");","tryCatchPattern":"try {\n  await setDisabledProviders(body);\n} catch (e) {\n  if (e.code === \"invalid_payload\") console.error(\"send a raw array: [\\\"anthropic\\\"]\", e.message);\n  else throw e;\n}","preventionTips":["Never wrap the list in an object key","Always JSON.stringify and set Content-Type: application/json","Validate payload shape with Zod before sending"],"tags":["validation","http-400","payload"],"backgroundTag":"schema-validation-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}