{"record":{"id":"c2788e16b575b154","repo":"facebook/relay","slug":"invalid-glob-pattern","errorCode":null,"errorMessage":"Invalid glob pattern '{}': {}","messagePattern":"Invalid glob pattern '(.+?)': (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/graphql-ir-diff/src/lib.rs","lineNumber":804,"sourceCode":"            // allows parsing of \"query {...}\" with no name, all other options are default\n            default_anonymous_operation_name: Some(\"Anonymous\".intern()),\n            allow_custom_scalar_literals: true,\n        },\n    )\n    .map_err(|diagnostics| anyhow::anyhow!(diagnostics.iter().join(\"\\n\")))?;\n\n    Ok(Program::from_definitions(schema, ir))\n}\n\npub fn load_schema(schema_paths: Vec<String>) -> Result<Arc<SDLSchema>> {\n    // Collect (content, file_path) pairs for each schema file\n    let schema_files: Vec<(String, String)> = schema_paths\n        .clone()\n        .into_iter()\n        .map(|pattern| {\n            // expand if path contains \"*\"\n            let paths = glob::glob(&pattern)\n                .map_err(|e| anyhow!(\"Invalid glob pattern '{}': {}\", pattern, e))?;\n            let file_entries: Result<Vec<(String, String)>> = paths\n                .map(|entry| {\n                    let file_path =\n                        entry.map_err(|e| anyhow!(\"Failed to read glob entry: {}\", e))?;\n                    let file_path_str = file_path.to_string_lossy().to_string();\n                    let schema_bytes = fs::read(file_path)?;\n                    let content = String::from_utf8(schema_bytes)\n                        .map_err(|e| anyhow!(\"Cannot parse schema utf8 from bytes: {}\", e))?;\n                    Ok((content, file_path_str))\n                })\n                .collect();\n            file_entries\n        })\n        .collect::<Result<Vec<_>>>()?\n        .into_iter()\n        .flatten()\n        .collect();\n","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/graphql-ir-diff/src/lib.rs#L786-L822","documentation":"load_schema expands each entry of schema_paths as a glob pattern via the glob crate. If a pattern is malformed (e.g. unbalanced brackets, invalid recursion syntax), glob::glob returns an error which is wrapped as 'Invalid glob pattern'. The whole load fails before any file is read.","triggerScenarios":"Calling load_schema(vec![pattern]) or compare() with a pattern string the glob crate cannot compile — e.g. \"schema/**[\" or \"[a-\" ; empty or mis-escaped patterns.","commonSituations":"Config files or CLI args where patterns are hand-typed with typos; patterns interpolated from variables that contain stray '[' or ']'; Windows-style backslash paths mixed into glob syntax.","solutions":["Inspect the pattern echoed in the error and fix its glob syntax (balance brackets, valid wildcards *, ?, **).","Test the pattern in isolation (glob::glob(&pattern).unwrap()) before wiring it into config.","If the path is meant to be literal, escape glob metacharacters or ensure it contains no [ ] { } characters.","Validate patterns at config-load time with a small helper that calls glob::glob and reports a friendly error."],"exampleFix":"// before\nload_schema(vec![\"schemas/**[\".to_string()])?; // invalid pattern\n// after\nload_schema(vec![\"schemas/**/*.graphql\".to_string()])?;","handlingStrategy":"validation","validationCode":"fn valid_glob(pattern: &str) -> bool {\n    glob::glob(pattern).is_ok()\n}\n// assert all patterns compile before calling load_schema\nfor p in &schema_paths {\n    assert!(valid_glob(p), \"invalid glob pattern: {p}\");\n}","typeGuard":null,"tryCatchPattern":"let schema = load_schema(paths.clone()).map_err(|e| {\n    if e.to_string().starts_with(\"Invalid glob pattern\") {\n        anyhow!(\"config error: check schema_paths globs: {e}\")\n    } else { e }\n});","preventionTips":["Unit-test every glob pattern used in config with glob::glob(...).is_ok().","Escape or avoid literal [ ] { } in paths.","Prefer simple **/*.graphql-style patterns."],"tags":["glob","path","configuration","rust"],"backgroundTag":"invalid-glob-pattern","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}