{"record":{"id":"90688a4ebdc31a8e","repo":"withastro/astro","slug":"glob-patterns-cannot-start-with-set-the-ba","errorCode":null,"errorMessage":"Glob patterns cannot start with `../`. Set the `base` option to a parent directory instead.","messagePattern":"Glob patterns cannot start with `\\.\\./`\\. Set the `base` option to a parent directory instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/astro/src/content/loaders/glob.ts","lineNumber":86,"sourceCode":"}\n\nfunction checkPrefix(pattern: string | Array<string>, prefix: string) {\n\tif (Array.isArray(pattern)) {\n\t\treturn pattern.some((p) => p.startsWith(prefix));\n\t}\n\treturn pattern.startsWith(prefix);\n}\n\nexport const secretLegacyFlag = Symbol('astro.legacy-glob');\n\n/**\n * Loads multiple entries, using a glob pattern to match files.\n * @param pattern A glob pattern to match files, relative to the content directory.\n */\n\nexport function glob(globOptions: GlobOptions & { [secretLegacyFlag]?: boolean }): Loader {\n\tif (checkPrefix(globOptions.pattern, '../')) {\n\t\tthrow new Error(\n\t\t\t'Glob patterns cannot start with `../`. Set the `base` option to a parent directory instead.',\n\t\t);\n\t}\n\tif (checkPrefix(globOptions.pattern, '/')) {\n\t\tthrow new Error(\n\t\t\t'Glob patterns cannot start with `/`. Set the `base` option to a parent directory or use a relative path instead.',\n\t\t);\n\t}\n\n\tconst isLegacy = !!globOptions[secretLegacyFlag];\n\tconst userGenerateId =\n\t\tglobOptions?.generateId ?? ((opts: GenerateIdOptions) => generateIdDefault(opts, isLegacy));\n\t// Coerce to string so numeric ids from YAML don't cause Set strict-equality mismatches\n\t// against string store keys in the untouched-entries cleanup. See #17624.\n\tconst generateId = (opts: GenerateIdOptions) => String(userGenerateId(opts));\n\n\tconst fileToIdMap = new Map<string, string>();\n","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/withastro/astro/blob/d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca/packages/astro/src/content/loaders/glob.ts#L68-L104","documentation":"Thrown as a plain Error (no AstroError code) by the glob() loader constructor when any pattern starts with '../'. Parent-directory traversal via the pattern is disallowed for security and predictability; the documented escape hatch is to relocate the base directory itself.","triggerScenarios":"Calling glob({ pattern: '../shared/*.md' }) or glob({ pattern: ['../posts/*.md', 'local/*.md'] }) — any element of the pattern array beginning with '../'.","commonSituations":"Trying to pull in content from a sibling/parent directory (monorepo shared content, workspace packages); porting an existing glob from another tool that allowed '..'.","solutions":["Set the base option to the parent directory and use a non-'../' pattern: glob({ base: '../shared', pattern: '*.md' }).","Use an absolute file URL for base pointing at the parent directory.","If the content lives outside the project, consider symlinking it into the project tree or copying it."],"exampleFix":"// before\nglob({ pattern: '../shared/posts/*.md' })\n// after\nglob({ base: '../shared', pattern: 'posts/*.md' })","handlingStrategy":"validation","validationCode":"function normalizeGlobPattern(pattern: string | string[], base?: string) {\n  const arr = Array.isArray(pattern) ? pattern : [pattern];\n  for (const p of arr) {\n    if (p.startsWith('../')) throw new Error('Use base option instead of ../ in pattern');\n  }\n}","typeGuard":"const startsParentRelative = (p: string) => p.startsWith('../');","tryCatchPattern":null,"preventionTips":["Prefer the base option over '../' in patterns.","Keep content inside the project tree; symlink external content if needed.","Write a small wrapper that rejects '../' patterns in your own config."],"tags":["content-collections","loader","glob-loader","path","security"],"backgroundTag":null,"analyzedSha":"d081033d5fe8e8a68c4bbbad4af9d2deb9c74bca","analyzedAt":"2026-08-12T13:37:29.035Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}