{"record":{"id":"e977c9b4de32960e","repo":"aeron-io/aeron","slug":"service-id-outside-allowed-range-0-maxid-serviceid","errorCode":null,"errorMessage":"service id outside allowed range [0,${maxId}]: ${serviceId}","messagePattern":"service id outside allowed range \\[0,(.+?)\\]: (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"aeron-cluster/src/main/java/io/aeron/cluster/service/ClusteredServiceContainer.java","lineNumber":833,"sourceCode":"                throw new RuntimeException(ex);\n            }\n        }\n\n        /**\n         * Conclude configuration by setting up defaults when specifics are not provided.\n         */\n        @SuppressWarnings(\"MethodLength\")\n        public void conclude()\n        {\n            if ((boolean)IS_CONCLUDED_VH.getAndSet(this, true))\n            {\n                throw new ConcurrentConcludeException();\n            }\n\n            final int maxId = MAX_SERVICE_COUNT - 1;\n            if (serviceId < 0 || serviceId > maxId)\n            {\n                throw new ConfigurationException(\"service id outside allowed range [0,\" + maxId + \"]: \" + serviceId);\n            }\n\n            if (null == threadFactory)\n            {\n                threadFactory = Thread::new;\n            }\n\n            if (null == idleStrategySupplier)\n            {\n                idleStrategySupplier = Configuration.idleStrategySupplier(null);\n            }\n\n            if (null == appVersionValidator)\n            {\n                appVersionValidator = AppVersionValidator.SEMANTIC_VERSIONING_VALIDATOR;\n            }\n\n            if (null == epochClock)","sourceCodeStart":815,"sourceCodeEnd":851,"githubUrl":"https://github.com/aeron-io/aeron/blob/6d60124e15e35c11b49ba2e3c2c2858a09a18803/aeron-cluster/src/main/java/io/aeron/cluster/service/ClusteredServiceContainer.java#L815-L851","documentation":"Thrown as ConfigurationException when Context.serviceId(int) is set to a value outside the allowed range [0, MAX_SERVICE_COUNT - 1]. Each service container in a cluster must have a unique service id within this fixed maximum so slots in the service array and counters can be allocated.","triggerScenarios":"Calling context.serviceId(n) with n < 0 or n >= MAX_SERVICE_COUNT during Context.conclude(); computing the service id from configuration/env with an off-by-one or unparsed string; launching more service containers than the max count with sequential ids.","commonSituations":"Starting several containers in one JVM and generating ids incorrectly; external config supplying 1-based ids while Aeron expects 0-based; configuration file listing more services than supported.","solutions":["Set serviceId within [0, MAX_SERVICE_COUNT-1] (e.g. 0-based indexing for each container)","Fix the id source (config file/env parse) to produce a valid non-negative int","Check the MAX_SERVICE_COUNT constant for your Aeron version and keep the service count within it","Validate the id at startup before constructing the context"],"exampleFix":"// before\ncontext.serviceId(Integer.parseInt(config.serviceId)); // config uses 1,2,3...\n// after\nint id = Integer.parseInt(config.serviceId) - 1;\nif (id < 0 || id >= MAX_SERVICE_COUNT) throw new IllegalArgumentException(\"bad serviceId\");\ncontext.serviceId(id);","handlingStrategy":"validation","validationCode":"int maxId = MAX_SERVICE_COUNT - 1;\nif (serviceId < 0 || serviceId > maxId) {\n    throw new IllegalArgumentException(\"serviceId \" + serviceId + \" outside [0,\" + maxId + \"]\");\n}\ncontext.serviceId(serviceId);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 0-based service ids consistently across config and code","Clamp/validate ids at config load time","Cap the number of service containers to MAX_SERVICE_COUNT"],"tags":["aeron","cluster","configuration","service-id"],"backgroundTag":"value-out-of-range","analyzedSha":"6d60124e15e35c11b49ba2e3c2c2858a09a18803","analyzedAt":"2026-09-12T11:17:07.683Z","contentChangedAt":"2026-09-12T11:17:07.683Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}