{"record":{"id":"1ffd4f5fa213897f","repo":"QuantumNous/new-api","slug":"failed-to-create-channel","errorCode":null,"errorMessage":"Failed to create channel","messagePattern":"Failed to create channel","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/src/features/channels/hooks/use-channel-mutate-form.ts","lineNumber":131,"sourceCode":"                ...payload,\n                key_mode: data.key_mode,\n              }\n            : payload\n\n        const response = await updateChannel(\n          props.currentRow.id,\n          payloadWithKeyMode\n        )\n        if (!response.success) {\n          throw new Error(response.message || t(ERROR_MESSAGES.UPDATE_FAILED))\n        }\n        return SUCCESS_MESSAGES.UPDATED\n      }\n\n      const payload = transformFormDataToCreatePayload(data)\n      const response = await createChannel(payload)\n      if (!response.success) {\n        throw new Error(response.message || t(ERROR_MESSAGES.CREATE_FAILED))\n      }\n      return SUCCESS_MESSAGES.CREATED\n    },\n    onSuccess: (messageKey) => {\n      toast.success(t(messageKey))\n      props.onSuccess()\n    },\n    onError: (error: unknown) => {\n      toast.error(getErrorMessage(error) || t(ERROR_MESSAGES.CREATE_FAILED))\n    },\n  })\n}\n","sourceCodeStart":113,"sourceCodeEnd":144,"githubUrl":"https://github.com/QuantumNous/new-api/blob/e2c7aa7b102c2075eae2377df3508658d45e88dc/web/src/features/channels/hooks/use-channel-mutate-form.ts#L113-L144","documentation":"Fallback thrown by the channels form mutation when createChannel(payload) responds with success falsy and no message. The admin API refused to create the channel; transformFormDataToCreatePayload built the body, but the server rejected it. onError shows the thrown message or, failing that, the same generic text via getErrorMessage.","triggerScenarios":"POST /api/channel with a payload failing server validation; duplicate channel name/type constraint; invalid or empty multi-key input; non-admin session calling the admin route.","commonSituations":"First-time channel setup with a typo'd base_url or key; pasting a key with trailing whitespace/newlines the backend rejects; permission or login expired while the form was open.","solutions":["Inspect the POST /api/channel response body for the server's specific message.","Re-check required fields: name, type, key, base_url, models.","Trim the API key and ensure multi-line keys match the server's expected multi-key format.","Confirm the admin session is still valid (re-login) if the response is a 401-shaped envelope."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const required = [data.name, data.type, data.key, data.base_url]\nif (required.some((v) => !v || !String(v).trim())) {\n  toast.error('Fill all required fields: name, type, key, base URL')\n  return\n}","typeGuard":"const isCreateChannelPayload = (p: unknown): boolean =>\n  typeof p === 'object' && p !== null &&\n  typeof (p as { name?: unknown }).name === 'string' &&\n  (p as { name: string }).name.trim().length > 0","tryCatchPattern":"onError: (error: unknown) => {\n  toast.error(getErrorMessage(error) || t(ERROR_MESSAGES.CREATE_FAILED))\n  // keep the modal open with entered values for quick correction\n}","preventionTips":["Validate required form fields client-side before POST","Trim pasted API keys and normalize multi-key newlines","Watch the POST /api/channel response body for the specific rejected field"],"tags":["channels","admin","form","api-response"],"backgroundTag":null,"analyzedSha":"e2c7aa7b102c2075eae2377df3508658d45e88dc","analyzedAt":"2026-08-15T10:35:18.111Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}