{"record":{"id":"54afa6434a510644","repo":"QuantumNous/new-api","slug":"failed-to-update-channel","errorCode":null,"errorMessage":"Failed to update channel","messagePattern":"Failed to update channel","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/src/features/channels/hooks/use-channel-mutate-form.ts","lineNumber":123,"sourceCode":"          }\n        }\n        const payloadWithKeyMode =\n          canEditSensitive &&\n          props.isMultiKeyChannel &&\n          data.key?.trim() &&\n          data.key_mode\n            ? {\n                ...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    },","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/QuantumNous/new-api/blob/e2c7aa7b102c2075eae2377df3508658d45e88dc/web/src/features/channels/hooks/use-channel-mutate-form.ts#L105-L141","documentation":"Fallback thrown by the channels form mutation when updateChannel(id, payload) responds with success falsy and no message. The admin API rejected the channel update — validation failure, duplicate channel name, invalid key, or insufficient admin privilege. The server's message, when present, is shown instead.","triggerScenarios":"PUT /api/channel/:id with a payload failing server validation (bad base URL, empty model list, invalid key format); editing a channel that another admin deleted concurrently; non-root user hitting the admin route.","commonSituations":"Editing a channel with an expired or malformed provider API key; model list containing names the backend rejects; permission changed mid-session; channel id stale after a re-seed of the database.","solutions":["Read the PUT /api/channel/:id response body in DevTools — the message names the rejected field.","Fix the highlighted form fields (key format, base_url, models) and resubmit.","Refresh the channel list to confirm the row still exists; re-open the edit dialog if the id is stale.","Verify you are logged in as an admin with channel-edit rights."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!props.currentRow?.id) {\n  toast.error('Channel no longer exists. Refresh the list.')\n  return\n}","typeGuard":"const isChannelRow = (r: unknown): r is { id: number } =>\n  typeof r === 'object' && r !== null && typeof (r as { id?: unknown }).id === 'number'","tryCatchPattern":"// already the pattern in use-secure style mutations:\n// onError receives the thrown Error; keep the dialog open on validation-style failures\nonError: (error: unknown) => {\n  toast.error(getErrorMessage(error) || t(ERROR_MESSAGES.UPDATE_FAILED))\n  // keep form state so the user can fix fields and resubmit\n}","preventionTips":["Refresh the channel list before editing rows opened long ago","Trim keys/URLs in the form before submit to avoid server-side rejects","Confirm admin session validity when editing after idle periods"],"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"}