zed-industries/zed · error
{} should have an extension
Error message
{} should have an extension What it means
For non-stdin inputs the loader derives the parser from the file extension: .json parses one Example object, .jsonl parses line-delimited records. A path with no extension reaches a panic stating the file must carry one. Stdin ('-') defaults to jsonl, which is why piped input bypasses the check.
Source
Thrown at crates/edit_prediction_cli/src/example.rs:234
let mut examples = Vec::new();
for path in inputs {
let is_stdin = path.as_path() == Path::new("-");
let content = if is_stdin {
let mut buffer = String::new();
std::io::stdin()
.read_to_string(&mut buffer)
.expect("Failed to read from stdin");
buffer
} else {
std::fs::read_to_string(path)
.unwrap_or_else(|_| panic!("Failed to read path: {path:?}"))
};
let filename = path.file_stem().unwrap().to_string_lossy().to_string();
let ext = if !is_stdin {
path.extension()
.map(|ext| ext.to_string_lossy().to_string())
.unwrap_or_else(|| panic!("{} should have an extension", path.display()))
} else {
"jsonl".to_string()
};
match ext.as_ref() {
"json" => {
let mut example =
serde_json::from_str::<Example>(&content).unwrap_or_else(|error| {
panic!("Failed to parse example file: {}\n{error}", path.display())
});
if example.spec.name.is_empty() {
example.spec.name = filename;
}
examples.push(example);
}
"jsonl" => examples.extend(
content
.lines()View on GitHub (pinned to f4178619ac)
Solutions
- Rename the file with .json or .jsonl
- Or pipe it via stdin: cat file | edit-prediction-cli eval -
- Fix the producer script so generated files always carry an extension
Example fix
# before edit-prediction-cli eval inputs # panic: inputs should have an extension # after mv inputs inputs.jsonl edit-prediction-cli eval inputs.jsonl
Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
suffix = Path(path).suffix
assert suffix in {".json", ".jsonl"}, f"{path} must end in .json or .jsonl (or pipe it via '-')" Type guard
import pathlib
def has_example_extension(path: str) -> bool:
return pathlib.Path(path).suffix in {".json", ".jsonl"} Prevention
- Make producer scripts always write .json/.jsonl suffixes
- Pipe extension-less files through stdin instead of renaming ad hoc
- Check mv/cp commands in scripts for accidentally truncated names
When it happens
Trigger: Passing a file named without a suffix ('examples', 'input'); temp files created via mktemp without an extension; shell variables where the extension was accidentally stripped during string manipulation.
Common situations: Renamed downloads losing extensions; artifacts written by scripts that omit suffixes; copy-paste of example commands with truncated names.
Related errors
- Failed to read path: {path:?}
- Failed to parse example file: {} {error}
- Failed to parse example on {}:{} {error}
- {} has invalid example extension `{ext}`
- --languages and/or --extensions is required (use --list to s
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/4010ff5ae44386f4.
Report an issue: GitHub.