{"record":{"id":"341de14e2a719879","repo":"denoland/deno","slug":"pattern-is-too-long","errorCode":null,"errorMessage":"pattern is too long","messagePattern":"pattern is too long","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/deps/minimatch.js","lineNumber":257,"sourceCode":"        return expansions;\n      }\n    }\n  }\n});\n\n// node_modules/.deno/minimatch@10.2.5/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js\nvar require_assert_valid_pattern = __commonJS({\n  \"node_modules/.deno/minimatch@10.2.5/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js\"(exports) {\n    \"use strict\";\n    Object.defineProperty(exports, \"__esModule\", { value: true });\n    exports.assertValidPattern = void 0;\n    var MAX_PATTERN_LENGTH = 1024 * 64;\n    var assertValidPattern = (pattern) => {\n      if (typeof pattern !== \"string\") {\n        throw new TypeError(\"invalid pattern\");\n      }\n      if (pattern.length > MAX_PATTERN_LENGTH) {\n        throw new TypeError(\"pattern is too long\");\n      }\n    };\n    exports.assertValidPattern = assertValidPattern;\n  }\n});\n\n// node_modules/.deno/minimatch@10.2.5/node_modules/minimatch/dist/commonjs/brace-expressions.js\nvar require_brace_expressions = __commonJS({\n  \"node_modules/.deno/minimatch@10.2.5/node_modules/minimatch/dist/commonjs/brace-expressions.js\"(exports) {\n    \"use strict\";\n    Object.defineProperty(exports, \"__esModule\", { value: true });\n    exports.parseClass = void 0;\n    var posixClasses = {\n      \"[:alnum:]\": [\"\\\\p{L}\\\\p{Nl}\\\\p{Nd}\", true],\n      \"[:alpha:]\": [\"\\\\p{L}\\\\p{Nl}\", true],\n      \"[:ascii:]\": [\"\\\\x00-\\\\x7f\", false],\n      \"[:blank:]\": [\"\\\\p{Zs}\\\\t\", true],\n      \"[:cntrl:]\": [\"\\\\p{Cc}\", true],","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/denoland/deno/blob/89f33cbef296a2b287f323d42de54c871fa69c77/ext/node/polyfills/deps/minimatch.js#L239-L275","documentation":"minimatch caps pattern length at 65536 characters (MAX_PATTERN_LENGTH = 1024 * 64) to prevent pathological parsing work. A longer pattern throws a TypeError ('pattern is too long') before any matching happens, after the string-type check passes.","triggerScenarios":"One giant pattern string built from thousands of OR-joined alternatives; huge brace expansions ({a,b,c,...}); concatenating an entire exclusion list into a single pattern; unbounded user input appended to a glob.","commonSituations":"Build tools generating one pattern per source file and joining them; ignore-lists collapsed into one string; script- or model-generated patterns that enumerate vast alternative sets.","solutions":["Split into many small patterns and compile each: patterns.map(p => new minimatch.Minimatch(p))","Prune before joining — deduplicate and drop dead entries so the pattern stays hand-sized","For very large alternative sets, use a plain regex or prefix matching instead of one mega-glob"],"exampleFix":"// before\nconst ok = files.every((f) => minimatch(f, giantJoinedPattern));\n// after\nconst matchers = patterns.map((p) => new minimatch.Minimatch(p));\nconst ok = files.every((f) => matchers.some((m) => m.match(f)));","handlingStrategy":"validation","validationCode":"const MAX_PATTERN = 64 * 1024; // minimatch's MAX_PATTERN_LENGTH\nfor (const p of patterns) {\n  if (typeof p === \"string\" && p.length > MAX_PATTERN) {\n    throw new RangeError(\"glob pattern exceeds 65536 chars; split it into multiple patterns\");\n  }\n}","typeGuard":"const isShortPattern = (p) => typeof p === \"string\" && p.length <= 64 * 1024;","tryCatchPattern":"try { ok = minimatch(path, pattern); }\ncatch (e) {\n  if (e instanceof TypeError && e.message === \"pattern is too long\") {\n    ok = splitPattern(pattern).some((p) => minimatch(path, p));\n  } else throw e;\n}","preventionTips":["Keep globs hand-written and small","Store exclusion lists as arrays of patterns, never one concatenated string","Cap and validate the length of generated patterns before matching"],"tags":["minimatch","glob","pattern","limits"],"backgroundTag":null,"analyzedSha":"89f33cbef296a2b287f323d42de54c871fa69c77","analyzedAt":"2026-08-16T07:54:21.310Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}