facebook/relay · error
Failed to read glob entry: {}
Error message
Failed to read glob entry: {} What it means
During load_schema, each path yielded by a glob is opened; if a matched entry cannot be turned into a path or opened while walking (e.g. IO error on the entry itself), the error is wrapped as 'Failed to read glob entry'. The pattern was valid, but reading one of its results failed.
Source
Thrown at compiler/crates/graphql-ir-diff/src/lib.rs:808
)
.map_err(|diagnostics| anyhow::anyhow!(diagnostics.iter().join("\n")))?;
Ok(Program::from_definitions(schema, ir))
}
pub fn load_schema(schema_paths: Vec<String>) -> Result<Arc<SDLSchema>> {
// Collect (content, file_path) pairs for each schema file
let schema_files: Vec<(String, String)> = schema_paths
.clone()
.into_iter()
.map(|pattern| {
// expand if path contains "*"
let paths = glob::glob(&pattern)
.map_err(|e| anyhow!("Invalid glob pattern '{}': {}", pattern, e))?;
let file_entries: Result<Vec<(String, String)>> = paths
.map(|entry| {
let file_path =
entry.map_err(|e| anyhow!("Failed to read glob entry: {}", e))?;
let file_path_str = file_path.to_string_lossy().to_string();
let schema_bytes = fs::read(file_path)?;
let content = String::from_utf8(schema_bytes)
.map_err(|e| anyhow!("Cannot parse schema utf8 from bytes: {}", e))?;
Ok((content, file_path_str))
})
.collect();
file_entries
})
.collect::<Result<Vec<_>>>()?
.into_iter()
.flatten()
.collect();
if schema_files.is_empty() {
return Err(anyhow!(
"No schema loaded for paths: {}",
schema_paths.join(",")View on GitHub (pinned to 668b1b85e0)
Solutions
- Check the underlying IO error in the message and fix permissions or restore the missing entry.
- Remove or repair broken symlinks matched by the glob.
- Narrow the glob pattern so it only matches real schema files (e.g. '**/*.graphql') instead of broad '**'.
- Re-run the load; if it is a transient race, retry after the external process finishes.
Example fix
// before load_schema(vec!["schemas/**".to_string()])?; // matches broken symlink // after load_schema(vec!["schemas/**/*.graphql".to_string()])?;
Defensive patterns
Strategy: retry
Validate before calling
fn readable(path: &std::path::Path) -> bool {
std::fs::metadata(path).map(|m| m.is_file()).unwrap_or(false)
}
// filter glob matches before loading
let paths: Vec<String> = paths.into_iter().filter(|p| readable(std::path::Path::new(p))).collect(); Try / catch
match load_schema(patterns) {
Ok(schema) => schema,
Err(e) if e.to_string().contains("Failed to read glob entry") => {
std::thread::sleep(Duration::from_millis(200));
load_schema(patterns)? // one retry for transient races
}
Err(e) => return Err(e),
} Prevention
- Tighten globs to real schema extensions to skip symlinks/dirs.
- Avoid racing cleanup jobs over schema directories in CI.
- Check filesystem permissions for the schemas directory.
When it happens
Trigger: Calling load_schema/compare with a valid glob where a matched entry is unreadable: file deleted between glob and read, permission denied, entry is a broken symlink, or the glob recursed into a directory with restricted access.
Common situations: Races with other processes cleaning temp files; sandboxed CI runners lacking read permission on a directory; broken symlinks in a schemas directory; reading across mount points that disappeared.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- LocalPersister: Unable to read the {} file: {}
- Unable to canonicalize file {:?}. Error: {:?}
- Expect to be able to strip common_path from {:?} {:?}
- Invalid glob pattern '{}': {}
- Cannot parse schema utf8 from bytes: {}
AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02).
Data as JSON: /api/errors/83c3aa9432d9818b.
Report an issue: GitHub.