jaywink / matrix-alertmanager

A bot to receive Alertmanager webhook events and forward them to chosen rooms.
MIT License
76 stars 22 forks source link

App crashing with ERR_INVALID_URL #47

Closed tofuwabohu closed 1 week ago

tofuwabohu commented 3 weeks ago

I have the following entry in my docker compose file next to alertmanager, prometheus, etc:

  alertbot:
    image: jaywink/matrix-alertmanager:latest
    ports: 
      - "4051:3000"
    environment:
      - APP_PORT=4051
      - APP_ALERTMANAGER_SECRET=xxx
      - MATRIX_HOMESERVER_URL=matrix.private.coffee
      # The rooms to send alerts to, separated by a |
      # Each entry contains the receiver name (from alertmanager) and the
      # internal id (not the public alias) of the Matrix channel to forward to.
      - MATRIX_ROOMS=matrix/!xxx:private.coffee
      - MATRIX_TOKEN=syt_xx
      - MATRIX_USER=@xxx:private.coffee
      # Set this to 1 to make firing alerts do a `@room` mention.
      # NOTE! Bot should also have enough power in the room for this to be useful.
      - MENTION_ROOM=0
    networks:
      - back-tier

Every time I start the container with docker compose up, I get the following error and the container crashes:

alertbot-1 | alertbot-1 | > matrix-alertmanager@0.7.2 start alertbot-1 | > node src/app.js alertbot-1 | alertbot-1 | initialization failed alertbot-1 | TypeError [ERR_INVALID_URL]: Invalid URL alertbot-1 | at new NodeError (node:internal/errors:399:5) alertbot-1 | at new URL (node:internal/url:560:13) alertbot-1 | at MatrixHttpApi.getUrl (/app/node_modules/matrix-js-sdk/lib/http-api/fetch.js:263:17) alertbot-1 | at MatrixHttpApi.request (/app/node_modules/matrix-js-sdk/lib/http-api/fetch.js:170:26) alertbot-1 | at MatrixHttpApi.authedRequest (/app/node_modules/matrix-js-sdk/lib/http-api/fetch.js:129:33) alertbot-1 | at MatrixClient.getJoinedRooms (/app/node_modules/matrix-js-sdk/lib/client.js:6146:22) alertbot-1 | at Object.init (/app/src/client.js:29:45) alertbot-1 | at Object. (/app/src/app.js:15:8) alertbot-1 | at Module._compile (node:internal/modules/cjs/loader:1254:14) alertbot-1 | at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) { alertbot-1 | input: 'matrix.private.coffee/_matrix/client/r0/joined_rooms', alertbot-1 | code: 'ERR_INVALID_URL' alertbot-1 | } alertbot-1 | npm notice alertbot-1 | npm notice New major version of npm available! 9.5.1 -> 10.8.2 alertbot-1 | npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.8.2 alertbot-1 | npm notice Run npm install -g npm@10.8.2 to update! alertbot-1 | npm notice

I tried another user on Matrix.com with the proper token and homeserver but get the same error.

jaywink commented 1 week ago

So as per https://github.com/jaywink/matrix-alertmanager/blob/master/.env.default#L3 your MATRIX_HOMESERVER_URL=matrix.private.coffee needs to be MATRIX_HOMESERVER_URL=https://matrix.private.coffee ie with the protocol part to be a proper URL.

Sorry for the slow response :) Please reopen if things still don't work.