{"record":{"id":"70515ff88fe57fa5","repo":"can1357/oh-my-pi","slug":"error-70515f","errorCode":null,"errorMessage":"{}","messagePattern":"\\{\\}","errorType":"exception","errorClass":"SortError","httpStatus":null,"severity":"error","filePath":"crates/pi-builtins/src/sort.rs","lineNumber":2596,"sourceCode":"const NEGATIVE: &u8 = &b'-';\nconst POSITIVE: &u8 = &b'+';\n\n// The automatic buffer heuristics clamp to this range to avoid\n// over-committing memory on constrained systems while still keeping\n// reasonably large chunks for typical workloads.\nconst MIN_AUTOMATIC_BUF_SIZE: usize = 512 * 1024; // 512 KiB\nconst FALLBACK_AUTOMATIC_BUF_SIZE: usize = 32 * 1024 * 1024; // 32 MiB\nconst MAX_AUTOMATIC_BUF_SIZE: usize = 1024 * 1024 * 1024; // 1 GiB\n\n#[derive(Debug, Error)]\npub enum SortError {\n\t#[error(\"{0}\")]\n\tMessage(String),\n\n\t#[error(\"write failed: {}: {}\", .path.maybe_quote(), strip_errno(.error))]\n\tWriteFailed { path: OsString, error: std::io::Error },\n\n\t#[error(\"{}\", format_disorder(.file, .line_number, .line, .silent))]\n\tDisorder { file: OsString, line_number: usize, line: String, silent: bool },\n\n\t#[error(\"open failed: {}: {}\", .path.maybe_quote(), strip_errno(.error))]\n\tOpenFailed { path: PathBuf, error: std::io::Error },\n\n\t#[error(\"cannot read: {}: {}\", .path.maybe_quote(), strip_errno(.error))]\n\tReadFailed { path: PathBuf, error: std::io::Error },\n\n\t#[error(\"failed to open temporary file: {}\", strip_errno(.error))]\n\tOpenTmpFileFailed { error: std::io::Error },\n\n\t#[error(\"could not run compress program '{}': {}\", .prog, strip_errno(.error))]\n\tCompressProgExecutionFailed { prog: String, error: std::io::Error },\n\n\t#[error(\"{} terminated abnormally\", .prog.quote())]\n\tCompressProgTerminatedAbnormally { prog: String },\n\n\t#[error(\"cannot create temporary file in {}:\", .path.quote())]","sourceCodeStart":2578,"sourceCodeEnd":2614,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/crates/pi-builtins/src/sort.rs#L2578-L2614","documentation":"`SortError::Disorder` reports that input lines violated the expected ordering, formatted via `format_disorder` with the file, line number, offending line, and a silent flag. The sort builtin raises it when operating in a mode that verifies order (e.g. `-c`/check) and the input is not sorted.","triggerScenarios":"Running sort in check mode (`sort -c`) against an unsorted file, causing the first out-of-order line to be reported.","commonSituations":"Validating that a pipeline output is sorted before consuming it; CI checks asserting sorted data files; a locale change (LC_ALL) making previously 'sorted' data appear out of order.","solutions":["Sort the file first (`sort file`) or regenerate the input in sorted order.","Ensure the same sort key/collation settings are used when producing and checking (set LC_ALL consistently, e.g. LC_ALL=C).","If the disorder is expected, use `-m` (merge) or remove the check flag.","Check the reported line number to find the first offending record and fix data upstream."],"exampleFix":"// before\nsort -c data.txt   # data.txt unsorted\n\n// after\nLC_ALL=C sort data.txt > data.sorted.txt && LC_ALL=C sort -c data.sorted.txt","handlingStrategy":"validation","validationCode":"// pre-check ordering with the same collation used by sort\nlet status = std::process::Command::new(\"sort\")\n    .args([\"-c\", path])\n    .env(\"LC_ALL\", \"C\")\n    .status()?;\nif !status.success() { eprintln!(\"{path} is not sorted (LC_ALL=C)\"); }","typeGuard":null,"tryCatchPattern":"match sort_result {\n    Err(SortError::Disorder { file, line_number, line, silent }) => {\n        eprintln!(\"{}:{}: disorder: {}\", file.display(), line_number, line);\n    }\n    Err(e) => eprintln!(\"sort: {e}\"),\n    Ok(_) => {}\n}","preventionTips":["Generate inputs with the same LC_ALL/collation used to check them.","Standardize on LC_ALL=C for deterministic ordering in pipelines.","Sort data before enabling any check (-c) mode."],"tags":["sort","validation","ordering","check-mode"],"backgroundTag":"input-not-sorted","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}