{"record":{"id":"bba651c8dbd53954","repo":"quarkusio/quarkus","slug":"invalid-lightness-number-needs-to-be-between-0-an","errorCode":null,"errorMessage":"Invalid lightness, number needs to be between 0 and 100. 0% is black, 50% is normal, and 100% is white","messagePattern":"Invalid lightness, number needs to be between 0 and 100\\. 0% is black, 50% is normal, and 100% is white","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/devui/deployment/src/main/java/io/quarkus/devui/deployment/BuildTimeContentProcessor.java","lineNumber":1341,"sourceCode":"        private int saturation; // Defines the saturation; 0% is a shade of gray and 100% is the full color (full saturation)\n        private int lightness; // Defines the lightness; 0% is black, 50% is normal, and 100% is white\n        private double alpha; // Defines the opacity; 0 is fully transparent, 100 is not transparent at all\n\n        private Color(int hue, int saturation, int lightness, double alpha) {\n            if (hue < 0 || hue > 360) {\n                throw new RuntimeException(\n                        \"Invalid hue, number needs to be between 0 and 360. Defines a degree on the color wheel\");\n            }\n            this.hue = hue;\n\n            if (saturation < 0 || saturation > 100) {\n                throw new RuntimeException(\n                        \"Invalid saturation, number needs to be between 0 and 100. 0% is a shade of gray and 100% is the full color (full saturation)\");\n            }\n            this.saturation = saturation;\n\n            if (lightness < 0 || lightness > 100) {\n                throw new RuntimeException(\n                        \"Invalid lightness, number needs to be between 0 and 100. 0% is black, 50% is normal, and 100% is white\");\n            }\n            this.lightness = lightness;\n\n            if (alpha < 0 || alpha > 1) {\n                throw new RuntimeException(\n                        \"Invalid alpha, number needs to be between 0 and 1. 0 is fully transparent, 1 is not transparent at all\");\n            }\n            this.alpha = alpha;\n        }\n\n        @Override\n        public String toString() {\n            return \"hsla(\" + this.hue + \", \" + this.saturation + \"%, \" + this.lightness + \"%, \" + this.alpha + \")\";\n        }\n\n        static Color from(Color color, double alpha) {\n            return new Color(color.hue, color.saturation, color.lightness, alpha);","sourceCodeStart":1323,"sourceCodeEnd":1359,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/devui/deployment/src/main/java/io/quarkus/devui/deployment/BuildTimeContentProcessor.java#L1323-L1359","documentation":"The BuildTimeContentProcessor.Color record validates the HSL color components used to generate per-extension Dev UI theme colors. This error is thrown by the Color constructor when the lightness is outside 0–100, since lightness is a percentage (0 = black, 50 = normal, 100 = white).","triggerScenarios":"Constructing a Color with a negative lightness or lightness greater than 100 during build-time Dev UI content generation.","commonSituations":"A custom extension passing an 0–1 lightness value without converting to percent; CSS-style lightness strings parsed as floats and mis-scaled; typo in a hardcoded theme value.","solutions":["Scale 0–1 lightness to percent: lightness = Math.round(l01 * 100)","Clamp with Math.max(0, Math.min(100, lightness)) before constructing the Color","Fix the hardcoded or computed value to lie within 0–100"],"exampleFix":"// before\nColor c = new Color(210, 60, 0.5, 1.0); // 0.5 is 0-1 scale\n// after\nColor c = new Color(210, 60, (int) Math.round(0.5 * 100), 1.0);","handlingStrategy":"validation","validationCode":"int l = (int) Math.round(light01 * 100); // convert 0-1 to percent\nif (l < 0 || l > 100) throw new IllegalArgumentException(\"lightness must be 0-100\");","typeGuard":"boolean isValidLightness(int l) { return l >= 0 && l <= 100; }","tryCatchPattern":"try {\n    Color c = new Color(hue, sat, light, alpha);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Invalid lightness\")) {\n        c = new Color(hue, sat, Math.max(0, Math.min(100, light)), alpha);\n    } else throw e;\n}","preventionTips":["Convert 0–1 floats to percent before passing lightness","Clamp lightness at call sites","Test boundaries 0 and 100"],"tags":["devui","build-time","color","argument-validation"],"backgroundTag":"invalid-argument-range","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}