{"record":{"id":"38a87c92683ce585","repo":"louislam/uptime-kuma","slug":"additional-headers-is-not-a-valid-json-38a87c","errorCode":null,"errorMessage":"Additional Headers is not a valid JSON","messagePattern":"Additional Headers is not a valid JSON","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/notification-providers/webhook.js","lineNumber":54,"sourceCode":"                    config.params.monitor = JSON.stringify(monitorJSON);\n                }\n            } else if (notification.webhookContentType === \"form-data\") {\n                const formData = new FormData();\n                formData.append(\"data\", JSON.stringify(data));\n                config.headers = formData.getHeaders();\n                data = formData;\n            } else if (notification.webhookContentType === \"custom\") {\n                data = await this.renderTemplate(notification.webhookCustomBody, msg, monitorJSON, heartbeatJSON);\n            }\n\n            if (notification.webhookAdditionalHeaders) {\n                try {\n                    config.headers = {\n                        ...config.headers,\n                        ...JSON.parse(notification.webhookAdditionalHeaders),\n                    };\n                } catch (err) {\n                    throw new Error(\"Additional Headers is not a valid JSON\");\n                }\n            }\n\n            config = this.getAxiosConfigWithProxy(config);\n\n            if (httpMethod === \"get\") {\n                await axios.get(notification.webhookURL, config);\n            } else {\n                await axios.post(notification.webhookURL, data, config);\n            }\n\n            return okMsg;\n        } catch (error) {\n            this.throwGeneralAxiosError(error);\n        }\n    }\n}\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/notification-providers/webhook.js#L36-L72","documentation":"Thrown by the Webhook provider when JSON.parse fails on notification.webhookAdditionalHeaders. Identical pattern to the SMTP additional-headers check: the field must be a JSON object whose keys become HTTP headers on the outgoing webhook request.","triggerScenarios":"Header list entered as newline-separated 'Key: Value' text, single-quoted JSON, trailing commas, pasted from a .env file, or templated with characters that break JSON.","commonSituations":"User copies headers from a Postman/curl -H list, uses YAML syntax, or includes a Bearer token with characters that need escaping.","solutions":["Wrap the value in {} and quote all keys and string values with double quotes.","Use a JSON linter before saving.","Remove comments/trailing commas; JSON forbids both.","For auth headers, ensure the value is a JSON string: {\"Authorization\":\"Bearer xyz\"}."],"exampleFix":"// before (notification config)\nwebhookAdditionalHeaders: Authorization: Bearer abc\nContent-Type: application/json\n// after\nwebhookAdditionalHeaders: {\"Authorization\":\"Bearer abc\",\"Content-Type\":\"application/json\"}","handlingStrategy":"validation","validationCode":"// Validate the webhook additional-headers string before merging\nfunction parseWebhookHeaders(raw) {\n    if (!raw) return {};\n    let parsed;\n    try { parsed = JSON.parse(raw); } catch (e) {\n        throw new Error(`Additional Headers is not valid JSON: ${e.message}`);\n    }\n    if (typeof parsed !== \"object\" || Array.isArray(parsed) || parsed === null) {\n        throw new Error(\"Additional Headers must be a JSON object\");\n    }\n    return parsed;\n}\nconfig.headers = { ...config.headers, ...parseWebhookHeaders(notification.webhookAdditionalHeaders) };","typeGuard":"/** True when raw parses to a flat header-string object. */\nfunction isValidHeadersObject(raw) {\n    try {\n        const o = JSON.parse(raw);\n        return o && typeof o === \"object\" && !Array.isArray(o) &&\n            Object.values(o).every((v) => typeof v === \"string\");\n    } catch { return false; }\n}","tryCatchPattern":"try {\n    config.headers = { ...config.headers, ...JSON.parse(notification.webhookAdditionalHeaders) };\n} catch (err) {\n    throw new Error(`Additional Headers is not a valid JSON: ${err.message}`);\n}","preventionTips":["Author headers as a JSON object, never as a curl -H list.","Add a live JSON validator in the UI field.","Avoid comments and trailing commas."],"tags":["webhook","notification-provider","config","json","validation"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}