louislam/uptime-kuma · error · Error

Invalid RabbitMQ Nodes

Error message

Invalid RabbitMQ Nodes

What it means

The RabbitMQ monitor stores its node list as a JSON string in monitor.rabbitmqNodes and parses it at the top of check(). If JSON.parse throws, the raw field is not valid JSON, and the catch rethrows a generic 'Invalid RabbitMQ Nodes' error that hides the original parse detail. This fires before any node is contacted, so it is purely a configuration-shape problem.

Source

Thrown at server/monitor-types/rabbitmq.js:17

const { MonitorType } = require("./monitor-type");
const { log, UP } = require("../../src/util");
const { axiosAbortSignal } = require("../util-server");
const axios = require("axios");

class RabbitMqMonitorType extends MonitorType {
    name = "rabbitmq";

    /**
     * @inheritdoc
     */
    async check(monitor, heartbeat, server) {
        let baseUrls = [];
        try {
            baseUrls = JSON.parse(monitor.rabbitmqNodes);
        } catch (error) {
            throw new Error("Invalid RabbitMQ Nodes");
        }

        if (baseUrls.length === 0) {
            throw new Error("No RabbitMQ nodes configured");
        }

        const errors = [];

        for (let i = 0; i < baseUrls.length; i++) {
            const baseUrl = baseUrls[i];
            const nodeIndex = i + 1;

            try {
                await this.checkSingleNode(monitor, baseUrl, `${nodeIndex}/${baseUrls.length}`);
                // If checkSingleNode succeeds (doesn't throw), set heartbeat to UP
                heartbeat.status = UP;
                heartbeat.msg =
                    baseUrls.length === 1

View on GitHub (pinned to 6b5ea01557)

Solutions

  1. Store the nodes as a JSON array of strings, e.g. ["http://rabbit-1:15672","http://rabbit-2:15672"].
  2. Validate the value with JSON.parse in a console before saving the monitor.
  3. Re-enter the nodes through the monitor editor so the frontend serializes them correctly.
  4. If editing the DB directly, wrap the list in brackets and double-quote each URL.

Example fix

// before
monitor.rabbitmqNodes = "http://rabbit-1:15672, http://rabbit-2:15672";
// after
monitor.rabbitmqNodes = JSON.stringify(["http://rabbit-1:15672","http://rabbit-2:15672"]);
Defensive patterns

Strategy: validation

Validate before calling

function parseRabbitNodes(raw) {
  if (typeof raw !== 'string' || raw.trim() === '') {
    throw new Error('rabbitmqNodes is empty');
  }
  let arr;
  try { arr = JSON.parse(raw); }
  catch (e) { throw new Error(`rabbitmqNodes is not valid JSON: ${e.message}`); }
  if (!Array.isArray(arr)) throw new Error('rabbitmqNodes must be a JSON array');
  return arr;
}

Type guard

function isJsonStringArray(s) {
  try {
    const v = JSON.parse(s);
    return Array.isArray(v) && v.every(x => typeof x === 'string');
  } catch { return false; }
}

Try / catch

try {
  await rabbitmqMonitor.check(monitor, heartbeat, server);
} catch (e) {
  if (/Invalid RabbitMQ Nodes/.test(e.message)) {
    // prompt user to re-enter nodes via the editor; do not retry blindly
    log.error('Reconfigure rabbitmqNodes as a JSON array of URLs');
  }
  throw e;
}

Prevention

When it happens

Trigger: monitor.rabbitmqNodes contains a non-JSON string: a comma-separated list like 'http://host:15672', a bare URL, trailing commas, single quotes, or accidental whitespace/newlines that break the parser.

Common situations: User types URLs separated by commas instead of a JSON array; UI or migration left a malformed value; someone edited the DB directly; mixing double/single quotes.

Related errors


AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12). Data as JSON: /api/errors/f117b625159b1c8d. Report an issue: GitHub.