affaan-m/ECC · error

invalid Discord webhook URL

Error message

invalid Discord webhook URL

What it means

normalizeDiscordWebhookUrl parses the configured webhook and rejects anything that is not an https URL on discord.com — protecting against SSRF and credential leakage to arbitrary hosts. Parse failure, wrong protocol, or wrong host all land here.

Source

Thrown at scripts/discord/announcement-core.mjs:58

      description,
      url: String(url || ''),
      footer: { text: footer },
    }],
  };
}

export function findDiscordReceipt(messages, key) {
  const discussionId = String(key).split(':').at(-1);
  return messages.find(message => message.embeds?.some(embed => embed.footer?.text === `ecc:${discussionId}`)) || null;
}

export function normalizeDiscordWebhookUrl(value) {
  const raw = String(value || '').trim();
  let parsed;
  try {
    parsed = new URL(raw);
  } catch {
    throw new Error('invalid Discord webhook URL');
  }
  if (parsed.protocol !== 'https:' || parsed.hostname !== 'discord.com' || parsed.port || parsed.username || parsed.password || parsed.search || parsed.hash) {
    throw new Error('invalid Discord webhook URL');
  }
  if (!/^\/api\/webhooks\/\d{10,25}\/[A-Za-z0-9._-]{20,}$/.test(parsed.pathname)) {
    throw new Error('invalid Discord webhook URL');
  }
  parsed.search = '?wait=true';
  return parsed.toString();
}

export function discussionReceiptMarker(key) {
  return `<!-- ecc-discord-receipt:${createHash('sha256').update(String(key)).digest('hex').slice(0, 32)} -->`;
}

export function findDiscussionReceipt(comments, marker) {
  const trusted = comments.filter(comment => (
    ['github-actions', 'github-actions[bot]'].includes(comment?.author?.login)

View on GitHub (pinned to 06c5e118c4)

Solutions

  1. Correct the value to one of the accepted options listed in the error message.
Defensive patterns

Strategy: validation

When it happens

Trigger: Triggered when announcement-core.mjs rejects the current invocation: invalid Discord webhook URL

Common situations: Occurs while running scripts/discord/announcement-core.mjs with invalid arguments, missing flags, or a failing external dependency; the guard at scripts/discord/announcement-core.mjs:58 aborts the command with this message.


AI-assisted analysis of affaan-m/ECC@06c5e118c4 (2026-08-18). Data as JSON: /api/errors/d76721727023c844. Report an issue: GitHub.