{"record":{"id":"1b385e7c39136a08","repo":"apple/pkl","slug":"invalidglobinvalidterminatingcharacter","errorCode":"invalidGlobInvalidTerminatingCharacter","errorMessage":"invalidGlobInvalidTerminatingCharacter","messagePattern":"invalidGlobInvalidTerminatingCharacter","errorType":"error_code","errorClass":"InvalidGlobPatternException","httpStatus":null,"severity":"error","filePath":"pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java","lineNumber":185,"sourceCode":"        case '}' -> {\n          if (inGroup) {\n            inGroup = false;\n            sb.append(\"))\");\n          } else {\n            sb.append('}');\n          }\n        }\n        case ',' -> {\n          if (inGroup) {\n            sb.append(\")|(?:\");\n          } else {\n            sb.append(',');\n          }\n        }\n        case '\\\\' -> {\n          var next = getNextChar(globPattern, i);\n          if (next == NULL) {\n            throw new InvalidGlobPatternException(\n                ErrorMessages.create(\"invalidGlobInvalidTerminatingCharacter\"));\n          }\n          if (next != '?' && next != '*' && next != '[' && next != '{' && next != '\\\\') {\n            throw new InvalidGlobPatternException(\n                ErrorMessages.create(\"invalidGlobInvalidEscapeCharacter\", next));\n          }\n          sb.append('\\\\').append(next);\n          i++;\n        }\n        case '[' -> i = consumeCharacterClass(globPattern, i, sb);\n        case '?' -> {\n          var next = getNextChar(globPattern, i);\n          if (next == '(') {\n            throw new InvalidGlobPatternException(ErrorMessages.create(\"invalidGlobExtGlob\"));\n          }\n          sb.append(\".\");\n        }\n        case '*' -> {","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/apple/pkl/blob/f3efcbfc9b60d30053b0536d664948d7aa1b8673/pkl-core/src/main/java/org/pkl/core/util/GlobResolver.java#L167-L203","documentation":"A backslash in a glob must escape one of the special characters `?`, `*`, `[`, `{`, or `\\`. If a trailing `\\` has no following character (getNextChar returns NULL), toRegexString throws InvalidGlobPatternException with this code indicating an invalid terminating character.","triggerScenarios":"Passing a glob ending in a bare backslash (e.g. `src\\\\` on a path or in JSON/YAML where `\\\\` collapsed to a single `\\\\`) to GlobResolver.toRegexString/toRegexPattern.","commonSituations":"Windows-style paths pasted into glob patterns; config files or shell quoting eating one level of backslashes; intending a literal trailing backslash in a directory name.","solutions":["Remove the trailing backslash from the pattern.","If escaping a literal special character, ensure a valid escapable character (`? * [ { \\\\`) follows the backslash.","Fix quoting/escaping in the config source so the intended number of backslashes reaches the resolver."],"exampleFix":"// before\nglob = \"src\\\\\"\n// after\nglob = \"src/**\"","handlingStrategy":"validation","validationCode":"if (glob.endsWith(\"\\\\\")) throw new IllegalArgumentException(\"Glob must not end with a bare backslash: \" + glob);\n","typeGuard":null,"tryCatchPattern":"try { return GlobResolver.toRegexPattern(glob); } catch (InvalidGlobPatternException e) { throw new IllegalArgumentException(\"Invalid escape in glob: \" + glob, e); }\n","preventionTips":["Never end globs with a backslash.","Double-check backslash escaping through config files/shells.","Prefer forward slashes in glob patterns."],"tags":["pkl","glob","pattern","escaping"],"backgroundTag":"invalid-regex-pattern","analyzedSha":"f3efcbfc9b60d30053b0536d664948d7aa1b8673","analyzedAt":"2026-09-08T13:10:45.570Z","contentChangedAt":"2026-09-08T13:10:45.570Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}