louislam/uptime-kuma · error · Error
Additional Headers is not a valid JSON
Error message
Additional Headers is not a valid JSON
What it means
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.
Source
Thrown at server/notification-providers/webhook.js:54
config.params.monitor = JSON.stringify(monitorJSON);
}
} else if (notification.webhookContentType === "form-data") {
const formData = new FormData();
formData.append("data", JSON.stringify(data));
config.headers = formData.getHeaders();
data = formData;
} else if (notification.webhookContentType === "custom") {
data = await this.renderTemplate(notification.webhookCustomBody, msg, monitorJSON, heartbeatJSON);
}
if (notification.webhookAdditionalHeaders) {
try {
config.headers = {
...config.headers,
...JSON.parse(notification.webhookAdditionalHeaders),
};
} catch (err) {
throw new Error("Additional Headers is not a valid JSON");
}
}
config = this.getAxiosConfigWithProxy(config);
if (httpMethod === "get") {
await axios.get(notification.webhookURL, config);
} else {
await axios.post(notification.webhookURL, data, config);
}
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
View on GitHub (pinned to 6b5ea01557)
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"}.
Example fix
// before (notification config)
webhookAdditionalHeaders: Authorization: Bearer abc
Content-Type: application/json
// after
webhookAdditionalHeaders: {"Authorization":"Bearer abc","Content-Type":"application/json"} Defensive patterns
Strategy: validation
Validate before calling
// Validate the webhook additional-headers string before merging
function parseWebhookHeaders(raw) {
if (!raw) return {};
let parsed;
try { parsed = JSON.parse(raw); } catch (e) {
throw new Error(`Additional Headers is not valid JSON: ${e.message}`);
}
if (typeof parsed !== "object" || Array.isArray(parsed) || parsed === null) {
throw new Error("Additional Headers must be a JSON object");
}
return parsed;
}
config.headers = { ...config.headers, ...parseWebhookHeaders(notification.webhookAdditionalHeaders) }; Type guard
/** True when raw parses to a flat header-string object. */
function isValidHeadersObject(raw) {
try {
const o = JSON.parse(raw);
return o && typeof o === "object" && !Array.isArray(o) &&
Object.values(o).every((v) => typeof v === "string");
} catch { return false; }
} Try / catch
try {
config.headers = { ...config.headers, ...JSON.parse(notification.webhookAdditionalHeaders) };
} catch (err) {
throw new Error(`Additional Headers is not a valid JSON: ${err.message}`);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: User copies headers from a Postman/curl -H list, uses YAML syntax, or includes a Bearer token with characters that need escaping.
Related errors
- Additional Headers is not a valid JSON
- Kafka Producer Brokers must be valid JSON: ${e.message}
- Kafka Producer SASL Options must be valid JSON: ${e.message}
- RabbitMQ Nodes must be valid JSON: ${e.message}
- Conditions must be valid JSON: ${e.message}
AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12).
Data as JSON: /api/errors/38a87c92683ce585.
Report an issue: GitHub.