{"record":{"id":"7d83849734f2f69c","repo":"prestodb/presto","slug":"generic-internal-error-7d8384","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Invalid color index: ${index}","messagePattern":"Invalid color index: (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ColorFunctions.java","lineNumber":79,"sourceCode":"\n        private int getIndex()\n        {\n            return index;\n        }\n\n        public String getName()\n        {\n            return name;\n        }\n\n        public static SystemColor valueOf(int index)\n        {\n            for (SystemColor color : values()) {\n                if (index == color.getIndex()) {\n                    return color;\n                }\n            }\n            throw new PrestoException(GENERIC_INTERNAL_ERROR, \"Invalid color index: \" + index);\n        }\n    }\n\n    private ColorFunctions() {}\n\n    @ScalarFunction\n    @LiteralParameters(\"x\")\n    @SqlType(ColorType.NAME)\n    public static long color(@SqlType(\"varchar(x)\") Slice color)\n    {\n        int rgb = parseRgb(color);\n\n        if (rgb != -1) {\n            return rgb;\n        }\n\n        // encode system colors (0-15) as negative values, offset by one\n        try {","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/scalar/ColorFunctions.java#L61-L97","documentation":"SystemColor.valueOf(index) maps a numeric index to a predefined system color; if no registered color matches the index it is treated as an internal invariant violation and throws GENERIC_INTERNAL_ERROR rather than a user-facing argument error.","triggerScenarios":"Calling the internal ColorFunctions SystemColor.valueOf(long index) with an index not matching any system color (e.g. a corrupted or out-of-range color index decoded from stored data).","commonSituations":"Round-tripping color values through external storage that truncates or renumbers them; hand-crafted queries referencing color() output manipulated numerically.","solutions":["Only pass indices produced by the library's own color()/rgb() functions","Verify stored color values were not truncated to a smaller integer type","If hit via SQL, check the input expression feeding the color index"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"boolean ok = SystemColor.isKnownIndex(index);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only library-produced color indices"],"tags":["sql","scalar-function","internal-error","color"],"backgroundTag":"invalid-enum-index","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}