{"record":{"id":"6fd6cbe85918bf1f","repo":"quarkusio/quarkus","slug":"invalid-alpha-number-needs-to-be-between-0-and-1","errorCode":null,"errorMessage":"Invalid alpha, number needs to be between 0 and 1. 0 is fully transparent, 1 is not transparent at all","messagePattern":"Invalid alpha, number needs to be between 0 and 1\\. 0 is fully transparent, 1 is not transparent at all","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/devui/deployment/src/main/java/io/quarkus/devui/deployment/BuildTimeContentProcessor.java","lineNumber":1347,"sourceCode":"                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);\n        }\n\n        static Color from(int hue, int saturation, int lightness) {\n            return new Color(hue, saturation, lightness, 1);\n        }\n","sourceCodeStart":1329,"sourceCodeEnd":1365,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/devui/deployment/src/main/java/io/quarkus/devui/deployment/BuildTimeContentProcessor.java#L1329-L1365","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 alpha is outside 0–1, since alpha is an opacity factor (0 = fully transparent, 1 = fully opaque) — note this is the one component on a 0–1 scale rather than percent.","triggerScenarios":"Constructing a Color with a negative alpha or alpha greater than 1 during build-time Dev UI content generation.","commonSituations":"Passing alpha as a percentage (e.g. 100) when the constructor expects 0–1; using a CSS percent value without dividing by 100; typo in a hardcoded theme value.","solutions":["Convert percent alpha to 0–1: alpha = alphaPercent / 100.0","Clamp with Math.max(0.0, Math.min(1.0, alpha)) before constructing the Color","Fix the hardcoded or computed value to lie within 0–1"],"exampleFix":"// before\nColor c = new Color(210, 60, 50, 100); // percent, wrong scale\n// after\nColor c = new Color(210, 60, 50, 100 / 100.0);","handlingStrategy":"validation","validationCode":"double a = alphaPercent / 100.0; // convert percent to 0-1\nif (a < 0.0 || a > 1.0) throw new IllegalArgumentException(\"alpha must be 0-1\");","typeGuard":"boolean isValidAlpha(double a) { return a >= 0.0 && a <= 1.0; }","tryCatchPattern":"try {\n    Color c = new Color(hue, sat, light, alpha);\n} catch (RuntimeException e) {\n    if (e.getMessage().startsWith(\"Invalid alpha\")) {\n        c = new Color(hue, sat, light, Math.max(0.0, Math.min(1.0, alpha)));\n    } else throw e;\n}","preventionTips":["Remember alpha is 0–1 (unlike saturation/lightness percent)","Divide percent values by 100 before passing alpha","Clamp alpha at call sites and test boundaries 0.0 and 1.0"],"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-12T22:17:10.623Z"}