anomalyco/sst · error · VisibleError

Duplicate priority ${rule.priority} on listener "${rule.list

Error message

Duplicate priority ${rule.priority} on listener "${rule.listen}" in Service "${name}".

What it means

Within a single listener, each ALB rule priority must be unique; duplicates make evaluation order ambiguous and AWS would reject them. SST tracks seen priorities per listener (prioritiesByListener) and throws on the second occurrence.

Source

Thrown at platform/src/components/aws/service.ts:2734

    function createAlbListenerRules(
      attachment: NonNullable<typeof albAttachment>,
      albTargets: Record<string, lb.TargetGroup>,
    ) {
      const rules = attachment.rules;
      const prioritiesByListener = new Map<string, Set<number>>();

      for (const rule of rules) {
        if (rule.priority < 1 || rule.priority > 50000) {
          throw new VisibleError(
            `Priority ${rule.priority} must be between 1 and 50000 in Service "${name}". When sharing an ALB, ensure non-overlapping priority ranges across services.`,
          );
        }

        const seen =
          prioritiesByListener.get(rule.listen) ?? new Set();
        if (seen.has(rule.priority)) {
          throw new VisibleError(
            `Duplicate priority ${rule.priority} on listener "${rule.listen}" in Service "${name}".`,
          );
        }
        seen.add(rule.priority);
        prioritiesByListener.set(rule.listen, seen);

        if (
          !rule.conditions?.path &&
          !rule.conditions?.query &&
          !rule.conditions?.header
        ) {
          throw new VisibleError(
            `At least one condition (path, query, or header) must be set for rules on an external ALB in Service "${name}".`,
          );
        }

        const listenerParts = rule.listen.split("/");
        const listenerPort = parseInt(listenerParts[0]);

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Assign a distinct priority to each rule on the same listener
  2. Omit priority (or use unique auto values) when explicit ordering isn't required
  3. If rules are on different listeners (different listen ports), verify the listen values actually differ

Example fix

// before
rules: [{ listen: "443/https", priority: 10, conditions: { path: "/a/*" } },
        { listen: "443/https", priority: 10, conditions: { path: "/b/*" } }]
// after
rules: [{ listen: "443/https", priority: 10, conditions: { path: "/a/*" } },
        { listen: "443/https", priority: 20, conditions: { path: "/b/*" } }]
Defensive patterns

Strategy: validation

Validate before calling

const seen = new Map<string, Set<number>>();
for (const r of attachment.rules) {
  const s = seen.get(r.listen) ?? new Set();
  if (s.has(r.priority)) throw new Error(`duplicate priority ${r.priority} on ${r.listen}`);
  s.add(r.priority); seen.set(r.listen, s);
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Two rules in the same attachment with the same listen value (e.g. both "443/https") and the same priority number.

Common situations: Copy-pasting a rule and changing only the path condition; generating rules from a loop using the index of the wrong array; merging config files where both define priority 100.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/4dcd0a09b3d11fee. Report an issue: GitHub.