{"record":{"id":"a465af206821fa4b","repo":"facebook/relay","slug":"result-did-not-match-expected-format-please","errorCode":null,"errorMessage":"Result '{}' did not match expected format. Please return 'file_path:line_number:column_number'","messagePattern":"Result '(.+?)' did not match expected format\\. Please return 'file_path:line_number:column_number'","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/crates/relay-bin/src/main.rs","lineNumber":629,"sourceCode":"        project_name: String,\n        parent_type: String,\n        field_info: Option<FieldSchemaInfo>,\n    ) -> Result<Option<FieldDefinitionSourceInfo>, String> {\n        let entity_name = match field_info {\n            Some(field_info) => format!(\"{}.{}\", parent_type, field_info.name),\n            None => parent_type,\n        };\n        let result = Command::new(&self.locate_command)\n            .arg(project_name)\n            .arg(entity_name)\n            .output()\n            .map_err(|e| format!(\"Failed to run locate command: {}\", e))?;\n\n        let result = String::from_utf8(result.stdout).expect(\"Failed to parse output\");\n\n        // Parse file_path:line_number:column_number\n        let result_trimmed = result.trim();\n        let result = result_trimmed.split(':').collect::<Vec<_>>();\n        if result.len() != 3 {\n            return Err(format!(\n                \"Result '{}' did not match expected format. Please return 'file_path:line_number:column_number'\",\n                result_trimmed\n            ));\n        }\n        let file_path = result[0];\n        let line_number = result[1].parse::<u64>().unwrap() - 1;\n        let column_number = result[2].parse::<u64>().unwrap_or(1_u64) - 1;\n\n        Ok(Some(FieldDefinitionSourceInfo {\n            file_path: file_path.to_string(),\n            line_number,\n            column_number,\n            is_local: true,\n        }))\n    }\n}","sourceCodeStart":611,"sourceCodeEnd":647,"githubUrl":"https://github.com/facebook/relay/blob/668b1b85e06261aa3b58dabfc51f8b5524a70955/compiler/crates/relay-bin/src/main.rs#L611-L647","documentation":"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.","triggerScenarios":"A custom locate command (e.g. configured for IDE jumping) prints output that doesn't split into exactly 3 colon-separated segments.","commonSituations":"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.","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)"],"exampleFix":"// before (locate script)\necho \"Located at src/Foo.ts:10:3\"\n// after\necho \"src/Foo.ts:10:3\"","handlingStrategy":"validation","validationCode":"const out = execFileSync(locateCmd, [project, entity], { encoding: 'utf8' }).trim();\nif (!/^.+:\\d+:\\d+$/.test(out)) {\n  throw new Error(`Locate output malformed: \"${out}\"; expected file:line:column`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  resolveFieldDefinition(project, entity);\n} catch (e) {\n  if (/did not match expected format/.test(e.message)) {\n    console.error('Fix locate command to print only file_path:line_number:column_number.');\n  } else throw e;\n}","preventionTips":["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"],"tags":["cli","parsing","output-format","locate-command"],"backgroundTag":"unexpected-output-format","analyzedSha":"668b1b85e06261aa3b58dabfc51f8b5524a70955","analyzedAt":"2026-09-02T19:57:20.783Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}