facebook/relay · error
Result '{}' did not match expected format. Please return 'fi
Error message
Result '{}' did not match expected format. Please return 'file_path:line_number:column_number' What it means
resolve_field_definition runs the user-provided locate command and expects its stdout to be exactly 'file_path:line_number:column_number'. After trimming and splitting on ':' it requires exactly 3 parts; anything else (2 parts, 4 parts due to Windows drive letters or paths containing colons) produces this formatted error string.
Source
Thrown at compiler/crates/relay-bin/src/main.rs:629
project_name: String,
parent_type: String,
field_info: Option<FieldSchemaInfo>,
) -> Result<Option<FieldDefinitionSourceInfo>, String> {
let entity_name = match field_info {
Some(field_info) => format!("{}.{}", parent_type, field_info.name),
None => parent_type,
};
let result = Command::new(&self.locate_command)
.arg(project_name)
.arg(entity_name)
.output()
.map_err(|e| format!("Failed to run locate command: {}", e))?;
let result = String::from_utf8(result.stdout).expect("Failed to parse output");
// Parse file_path:line_number:column_number
let result_trimmed = result.trim();
let result = result_trimmed.split(':').collect::<Vec<_>>();
if result.len() != 3 {
return Err(format!(
"Result '{}' did not match expected format. Please return 'file_path:line_number:column_number'",
result_trimmed
));
}
let file_path = result[0];
let line_number = result[1].parse::<u64>().unwrap() - 1;
let column_number = result[2].parse::<u64>().unwrap_or(1_u64) - 1;
Ok(Some(FieldDefinitionSourceInfo {
file_path: file_path.to_string(),
line_number,
column_number,
is_local: true,
}))
}
}View on GitHub (pinned to 668b1b85e0)
Solutions
- Fix the locate command to print exactly file_path:line_number:column_number and nothing else
- Quote or normalize paths so they contain no ':' characters (or use relative paths)
- Test the locate command standalone: it should output a single line like 'src/x.ts:12:5'
- Update the locate script to strip extra output (stderr is ignored, so move diagnostics to stderr)
Example fix
// before (locate script) echo "Located at src/Foo.ts:10:3" // after echo "src/Foo.ts:10:3"
Defensive patterns
Strategy: validation
Validate before calling
const out = execFileSync(locateCmd, [project, entity], { encoding: 'utf8' }).trim();
if (!/^.+:\d+:\d+$/.test(out)) {
throw new Error(`Locate output malformed: "${out}"; expected file:line:column`);
} Try / catch
try {
resolveFieldDefinition(project, entity);
} catch (e) {
if (/did not match expected format/.test(e.message)) {
console.error('Fix locate command to print only file_path:line_number:column_number.');
} else throw e;
} Prevention
- Keep locate scripts single-purpose: one line of stdout only
- Send diagnostics to stderr, never stdout
- Avoid ':' inside file paths; test on Windows-style paths
- Unit-test the locate command's output format
When it happens
Trigger: A custom locate command (e.g. configured for IDE jumping) prints output that doesn't split into exactly 3 colon-separated segments.
Common situations: Locate script printing extra text or a trailing message; absolute Windows paths (C:\...) adding an extra colon segment; tool output lacking line/column numbers; scripts appending newline-separated warnings.
Related errors
- Failed to run locate command: {}
- Platform "${process.platform} (${process.arch})" not support
- No Relay config found from current directory. Pass --config
AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02).
Data as JSON: /api/errors/a465af206821fa4b.
Report an issue: GitHub.