{"record":{"id":"a6ac0d2a05a915ea","repo":"prestodb/presto","slug":"bad-type-signature-s","errorCode":null,"errorMessage":"Bad type signature: '%s'","messagePattern":"Bad type signature: '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java","lineNumber":292,"sourceCode":"                EnumMapParsingData enumMapParsingData = parseEnumMap(lowerCaseSignature, i);\n                parameterEnd = enumMapParsingData.mapEndIndex;\n                parsedEnumMaps.put(i, enumMapParsingData);\n            }\n            else if (distinctTypeStartIndices.contains(i)) {\n                DistinctTypeParsingData distinctTypeParsingData = DistinctTypeParsingData.parse(lowerCaseSignature, i);\n                parameterEnd = distinctTypeParsingData.endIndex;\n                parsedDistinctTypes.put(i, distinctTypeParsingData);\n            }\n            else if (c == ',') {\n                if (bracketCount == 1) {\n                    checkArgument(parameterStart >= 0, \"Bad type signature: '%s'\", signature);\n                    parameters.add(parseTypeSignatureParameter(signature, parameterStart, i, literalCalculationParameters, parsedEnumMaps, parsedDistinctTypes));\n                    parameterStart = i + 1;\n                }\n            }\n        }\n\n        throw new IllegalArgumentException(format(\"Bad type signature: '%s'\", signature));\n    }\n\n    private static class DistinctTypeParsingData\n    {\n        private final int endIndex;\n        private final DistinctTypeInfo distinctType;\n\n        private DistinctTypeParsingData(int endIndex, DistinctTypeInfo distinctType)\n        {\n            this.endIndex = endIndex;\n            this.distinctType = distinctType;\n        }\n\n        private static Optional<QualifiedObjectName> parseParentName(String s)\n        {\n            return s.equals(\"null\") ? Optional.empty() : Optional.of(QualifiedObjectName.valueOf(s));\n        }\n","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java#L274-L310","documentation":"TypeSignature.parseTypeSignature parses a type signature string (e.g. \"array(bigint)\", \"row(a int)\"). When the parser exhausts the input without reaching a complete, well-formed type — due to unbalanced parentheses, stray characters, or trailing garbage — it throws IllegalArgumentException with the offending signature.","triggerScenarios":"parseTypeSignature(\"...\") where the string is empty, has unbalanced '<'/'>', '(' or ')', contains an invalid parameter list, or has trailing characters after a complete type.","commonSituations":"Catalog/connector metadata returning hand-built or corrupted type strings; user-supplied type names passed through SQL-like config; version skew where a newer type syntax (e.g. distinct types, enum parameters) is parsed by an older engine.","solutions":["Inspect the signature string in the exception message and fix the syntax (balance parentheses/angle brackets, remove trailing tokens).","Verify the source of the string: catalog metadata, config file, or query output may be truncated or stale.","Check engine/plugin version compatibility for newer type-signature syntax (row fields, distinct types, enum literals).","Catch IllegalArgumentException around parseTypeSignature and surface a user-facing INVALID_TYPE_SIGNATURE error."],"exampleFix":"// before\nTypeSignature sig = parseTypeSignature(\"array(bigint\"); // throws\n// after\nTypeSignature sig;\ntry {\n    sig = parseTypeSignature(signature.trim());\n} catch (IllegalArgumentException e) {\n    throw new PrestoException(INVALID_TYPE_SIGNATURE, \"Invalid type: \" + signature, e);\n}","handlingStrategy":"try-catch","validationCode":"boolean balanced = true;\nint depth = 0;\nfor (char c : signature.toCharArray()) {\n    if (c == '<' || c == '(') depth++;\n    if (c == '>' || c == ')') depth--;\n    if (depth < 0) { balanced = false; break; }\n}\nif (signature.trim().isEmpty() || !balanced || depth != 0) {\n    throw new IllegalArgumentException(\"Malformed type signature: \" + signature);\n}","typeGuard":"boolean looksLikeTypeSignature(String s) {\n    return s != null && s.trim().matches(\"[a-zA-Z][a-zA-Z0-9_]*(\\\\(.*\\\\)|<.*>)?\");\n}","tryCatchPattern":"try {\n    sig = TypeSignature.parseTypeSignature(raw);\n} catch (IllegalArgumentException e) {\n    throw new PrestoException(INVALID_TYPE_SIGNATURE,\n        \"Cannot parse type signature '\" + raw + \"'\", e);\n}","preventionTips":["Validate type strings from catalogs/config before parsing.","Keep engine and connector-plugin versions aligned to support the same signature syntax.","Log the full signature string from the exception message when triaging.","Round-trip test generated type signatures (parse then render) in codegen."],"tags":["presto","type-signature","parsing","illegal-argument"],"backgroundTag":"type-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"}