{"record":{"id":"d3904bf5990630d2","repo":"anomalyco/sst","slug":"priority-rule-priority-must-be-between-1-and-50","errorCode":null,"errorMessage":"Priority ${rule.priority} must be between 1 and 50000 in Service \"${name}\". When sharing an ALB, ensure non-overlapping priority ranges across services.","messagePattern":"Priority (.+?) must be between 1 and 50000 in Service \"(.+?)\"\\. When sharing an ALB, ensure non-overlapping priority ranges across services\\.","errorType":"validation","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/service.ts","lineNumber":2726,"sourceCode":"          targetGroup: e.targetGroup,\n          containerName: e.explicitContainer ?? ctrs[0].name,\n          containerPort: e.containerPort,\n        })),\n      );\n\n      return { targets, entries };\n    }\n\n    function createAlbListenerRules(\n      attachment: NonNullable<typeof albAttachment>,\n      albTargets: Record<string, lb.TargetGroup>,\n    ) {\n      const rules = attachment.rules;\n      const prioritiesByListener = new Map<string, Set<number>>();\n\n      for (const rule of rules) {\n        if (rule.priority < 1 || rule.priority > 50000) {\n          throw new VisibleError(\n            `Priority ${rule.priority} must be between 1 and 50000 in Service \"${name}\". When sharing an ALB, ensure non-overlapping priority ranges across services.`,\n          );\n        }\n\n        const seen =\n          prioritiesByListener.get(rule.listen) ?? new Set();\n        if (seen.has(rule.priority)) {\n          throw new VisibleError(\n            `Duplicate priority ${rule.priority} on listener \"${rule.listen}\" in Service \"${name}\".`,\n          );\n        }\n        seen.add(rule.priority);\n        prioritiesByListener.set(rule.listen, seen);\n\n        if (\n          !rule.conditions?.path &&\n          !rule.conditions?.query &&\n          !rule.conditions?.header","sourceCodeStart":2708,"sourceCodeEnd":2744,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/service.ts#L2708-L2744","documentation":"ALB listener rules support priorities from 1 to 50000. When services share an external ALB, SST also requires that priorities don't overlap across services, so out-of-range values are rejected up front with a reminder about cross-service priority ranges.","triggerScenarios":"Defining a rule with priority: 0, a negative number, or anything above 50000 in an ALB attachment for Service \"name\".","commonSituations":"Using 0-based indexes from code into ALB's 1-based priorities; computing priorities dynamically from array positions; assuming large sentinel values (e.g. 999999 for 'last') are allowed.","solutions":["Set priority to an integer between 1 and 50000","When sharing an ALB, partition disjoint priority ranges per service (e.g. service A: 1-1000, service B: 1001-2000)","Remove explicit priority and let defaults apply if order doesn't matter"],"exampleFix":"// before\nrules: [{ priority: 0, ... }]\n// after\nrules: [{ priority: 1, ... }]","handlingStrategy":"validation","validationCode":"for (const r of attachment.rules)\n  if (!Number.isInteger(r.priority) || r.priority < 1 || r.priority > 50000)\n    throw new Error(`priority ${r.priority} out of range 1-50000`);","typeGuard":"const isValidPriority = (p: number): p is number =>\n  Number.isInteger(p) && p >= 1 && p <= 50000;","tryCatchPattern":"null","preventionTips":["Reserve disjoint priority ranges per service when sharing an ALB","Never use 0 or sentinel values like 999999","Centralize priority allocation in one config module"],"tags":["load-balancer","alb","validation","priority"],"backgroundTag":"invalid-priority-range","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}