{"record":{"id":"ba267bc030fc041b","repo":"apify/crawlee","slug":"cannot-parse-glob-pattern-globtrimmed-it-mus","errorCode":null,"errorMessage":"Cannot parse Glob pattern '${globTrimmed}': it must be an non-empty string","messagePattern":"Cannot parse Glob pattern '(.+?)': it must be an non-empty string","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/enqueue_links/shared.ts","lineNumber":148,"sourceCode":"            if (typeof item === 'string') {\n                globObject = { glob: validateGlobPattern(item) };\n            } else {\n                globObject = { glob: validateGlobPattern(item.glob) };\n            }\n\n            updateEnqueueLinksPatternCache(item, globObject);\n\n            return globObject;\n        });\n}\n\n/**\n * @internal\n */\nexport function validateGlobPattern(glob: string): string {\n    const globTrimmed = glob.trim();\n    if (globTrimmed.length === 0)\n        throw new Error(`Cannot parse Glob pattern '${globTrimmed}': it must be an non-empty string`);\n    return globTrimmed;\n}\n\n/**\n * Helper factory used in the `enqueueLinks()` and enqueueLinksByClickingElements() function\n * to check RegExps input and return valid RegExps.\n * @ignore\n */\nexport function constructRegExpObjectsFromRegExps(regexps: readonly RegExpInput[]): RegExpObject[] {\n    return regexps.map((item) => {\n        // Get regexp object from cache.\n        let regexpObject = enqueueLinksPatternCache.get(item);\n        if (regexpObject) return regexpObject;\n\n        if (item instanceof RegExp) {\n            regexpObject = { regexp: item };\n        } else {\n            regexpObject = { regexp: item.regexp };","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/apify/crawlee/blob/dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c/packages/core/src/enqueue_links/shared.ts#L130-L166","documentation":"enqueueLinks() validates each glob pattern with validateGlobPattern, which requires a non-empty (after trimming) string. An empty or whitespace-only glob cannot match any pseudo-URL, so the library throws immediately. Note the message has a typo: it says the value must be 'an non-empty string'.","triggerScenarios":"Passing globs: [''] or ['   '] (whitespace-only) to enqueueLinks() or enqueueLinksByClickingElements(); building globs from env/config values that resolve to empty strings.","commonSituations":"process.env.SITE_GLOB unset yielding ''; config files with placeholder empty entries; string-splitting producing empty elements (e.g. 'a,,b'.split(',')).","solutions":["Filter out empty/whitespace entries before passing globs","Validate the env/config value has a default fallback","Ensure patterns actually match target URLs (also check syntax)","Write the glob per pseudo-URL syntax, e.g. 'https://example.com/(.*)'"],"exampleFix":"// before\nawait enqueueLinks({ globs: (process.env.GLOB ?? '').split(',') });\n// after\nawait enqueueLinks({ globs: (process.env.GLOB ?? '').split(',').map((g) => g.trim()).filter(Boolean) });","handlingStrategy":"validation","validationCode":"const globs = rawGlobs.map((g) => g.trim()).filter((g) => g.length > 0);\nif (globs.length === 0) throw new Error('at least one non-empty glob required');","typeGuard":"const isValidGlob = (g: string): boolean => typeof g === 'string' && g.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Trim and filter glob arrays before calling enqueueLinks","Give env-based globs safe defaults","Avoid naive split(',') which yields empty entries"],"tags":["validation","enqueue-links","glob"],"backgroundTag":"invalid-glob-pattern","analyzedSha":"dbe57fb09ca607ad59dcf998f3925ef9ac3bb26c","analyzedAt":"2026-08-30T22:22:28.328Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}