{"record":{"id":"58fc9210944ccfc2","repo":"prestodb/presto","slug":"unexpected-varchar-value-in-numeric-enum-signature","errorCode":null,"errorMessage":"Unexpected varchar value in numeric enum signature","messagePattern":"Unexpected varchar value in numeric enum signature","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java","lineNumber":449,"sourceCode":"        Map<String, String> map = new HashMap<>();\n\n        for (int i = openBracketIndex + 1; i < signature.length(); i++) {\n            char c = signature.charAt(i);\n            if (state == EnumMapParsingState.IN_KEY_ESCAPE) {\n                state = EnumMapParsingState.IN_KEY;\n                keyOrValue.append(c);\n            }\n            if (state == EnumMapParsingState.IN_STR_VALUE_ESCAPE) {\n                state = EnumMapParsingState.IN_STR_VALUE;\n                keyOrValue.append(c);\n            }\n            else if (c == '\"') {\n                if (state == EnumMapParsingState.EXPECT_KEY) {\n                    state = EnumMapParsingState.IN_KEY;\n                }\n                else if (state == EnumMapParsingState.EXPECT_VALUE) {\n                    if (isBigintEnum) {\n                        throw new IllegalStateException(\"Unexpected varchar value in numeric enum signature\");\n                    }\n                    state = EnumMapParsingState.IN_STR_VALUE;\n                }\n                else if ((state == EnumMapParsingState.IN_KEY || state == EnumMapParsingState.IN_STR_VALUE)\n                        && i + 1 < signature.length() && signature.charAt(i + 1) == '\"') {\n                    state = state == EnumMapParsingState.IN_KEY ? EnumMapParsingState.IN_KEY_ESCAPE : EnumMapParsingState.IN_STR_VALUE_ESCAPE;\n                }\n                else if (state == EnumMapParsingState.IN_KEY) {\n                    state = EnumMapParsingState.EXPECT_COLON;\n                }\n                else if (state == EnumMapParsingState.IN_STR_VALUE) {\n                    state = EnumMapParsingState.EXPECT_COMMA_OR_CLOSING_BRACKET;\n                }\n                else {\n                    throw new IllegalStateException(\"Cannot parse enum signature\");\n                }\n            }\n            else if (state == EnumMapParsingState.IN_KEY || state == EnumMapParsingState.IN_STR_VALUE) {","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java#L431-L467","documentation":"parseEnumMap rejects a double-quoted (varchar) enum value encountered while the signature was declared as a numeric (BIGINT) enum. Enum signatures are either all-bigint-keyed or all-varchar-valued; mixing is invalid, so a '\"' in the value position of a numeric enum is a parse failure.","triggerScenarios":"Parsing a signature like 'ENUM<bigint>{1: \"one\"}' — i.e. a numeric enum whose value is quoted — via TypeSignature.parseTypeSignature / enumMapParsingData.","commonSituations":"Hand-written enum type signatures mixing value styles, code generators that emit quoted values regardless of base type, corrupted or edited persisted signatures.","solutions":["Remove the quotes so numeric values are bare: 'ENUM<bigint>{1: one, 2: two}'.","Ensure the enum base type matches the value style — use ENUM<varchar> if values are quoted strings.","Regenerate the signature from TypeSignatureSerialization so the format matches the declared base type."],"exampleFix":"// before\n\"ENUM<bigint>{1: \\\"one\\\"}\"\n// after\n\"ENUM<bigint>{1: one}\"","handlingStrategy":"validation","validationCode":"// bigint enums must not have quoted values\nboolean isBigintEnum = signature.contains(\"ENUM<bigint>\");\nint colon = signature.indexOf(':');\nif (isBigintEnum && colon != -1 && signature.charAt(signature.indexOf(':', colon + 1) + 1) == '\"') {\n    throw new IllegalArgumentException(\"quoted value in numeric enum: \" + signature);\n}","typeGuard":"static boolean valuesMatchEnumBase(String sig) {\n    boolean bigint = sig.contains(\"ENUM<bigint>\");\n    boolean hasQuotedValue = sig.contains(\": \\\\\"\") || sig.contains(\":\\\"\\\"\");\n    return bigint != hasQuotedValue || !bigint;\n}","tryCatchPattern":"try {\n    TypeSignature.parseTypeSignature(signature);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"varchar value in numeric enum\")) {\n        // strip quotes from values or re-map to ENUM<varchar>\n    } else throw e;\n}","preventionTips":["Match value style to the declared enum base type (bigint -> bare numbers, varchar -> quoted).","Generate enum signatures with a single code path, never by hand.","Round-trip enum signatures through toString/parse in tests."],"tags":["presto","type-signature","enum","parsing"],"backgroundTag":"enum-signature-parse-failure","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"}