{"record":{"id":"cf2a5ebb16034084","repo":"sxyazi/yazi","slug":"e-cf2a5e","errorCode":null,"errorMessage":"{e}","messagePattern":"\\{e\\}","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"yazi-vfs/src/engine/sftp/metadata.rs","lineNumber":70,"sourceCode":"\t\t\tmtime: attrs.mtime.and_then(|t| UNIX_EPOCH.checked_add(Duration::from_secs(t as u64))),\n\t\t\tdev: 0,\n\t\t\tuid: attrs.uid.unwrap_or(0),\n\t\t\tgid: attrs.gid.unwrap_or(0),\n\t\t\tnlink: 0,\n\t\t}))\n\t}\n}\n\n// --- ChaMode\npub(super) struct ChaMode(pub(super) yazi_fs::cha::ChaMode);\n\nimpl TryFrom<&yazi_sftp::fs::Attrs> for ChaMode {\n\ttype Error = io::Error;\n\n\tfn try_from(attrs: &yazi_sftp::fs::Attrs) -> Result<Self, Self::Error> {\n\t\tyazi_fs::cha::ChaMode::try_from(attrs.perm.unwrap_or_default() as u16)\n\t\t\t.map(Self)\n\t\t\t.map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))\n\t}\n}\n","sourceCodeStart":52,"sourceCodeEnd":73,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-vfs/src/engine/sftp/metadata.rs#L52-L73","documentation":"This error is produced when converting SFTP protocol `Attrs` permissions (`attrs.perm`, a u32 bitmask) into `ChaMode`: the perm field (defaulted to 0 when absent) is truncated to u16 and passed to `ChaMode::try_from`, which rejects values that don't form a valid Unix mode. The failure is mapped to InvalidData, so it indicates malformed or unsupported permission bits returned by the remote server.","triggerScenarios":"A remote SFTP server returns an `Attrs` whose perm field doesn't fit a valid Unix file-mode layout (extra/high bits beyond the u16 mode space), or omits perm so the defaulted 0/u16 conversion is rejected by ChaMode's validation.","commonSituations":"Non-Unix or quirky SFTP servers (Windows OpenSSH, some NAS/firmware servers) reporting permission fields differently, protocol-version mismatches producing unexpected flag combos, or servers returning perm=0 for entries without permission support.","solutions":["Check what the remote server reports for permissions (log attrs.perm) and confirm server/protocol compatibility","Update the sftp client/server so modes are reported in standard Unix layout","Sanitize the perm bits before conversion (mask to 0o7777) at the adapter layer if your server emits extra bits","Treat it as server data corruption: re-list the directory or reconnect and retry"],"exampleFix":"// before\nChaMode::try_from(attrs.perm.unwrap_or_default() as u16)\n// after (mask to valid mode bits first)\nChaMode::try_from((attrs.perm.unwrap_or_default() & 0o7777_777) as u16)","handlingStrategy":"try-catch","validationCode":"// Server-provided; can't pre-validate the caller's input, but you can sanity-check after stat\nlet perm = attrs.perm.unwrap_or_default();\nif perm & !0o7777_7777 != 0 { // unexpected high bits\n    log::warn!(\"server returned non-standard perm bits: {perm:#o}\");\n}","typeGuard":"fn is_representable_mode(perm: u32) -> bool {\n    u16::try_from(perm & 0xffff).is_ok() && yazi_fs::cha::ChaMode::try_from((perm & 0xffff) as u16).is_ok()\n}","tryCatchPattern":"match Cha::try_from((name, &attrs)) {\n    Ok(cha) => cha,\n    Err(e) if e.kind() == io::ErrorKind::InvalidData => {\n        // permission bits unusable — fall back to a default Cha\n        Cha::fallback(name)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Verify server compatibility: some SFTP servers (Windows, NAS firmware) report non-Unix perm fields","Mask perm to valid mode bits at the adapter layer before ChaMode conversion","Update the SFTP client/server when protocol quirks are the cause","On repeated failures, reconnect and re-stat to rule out corrupted listings"],"tags":["sftp","permissions","metadata","invalid-data"],"backgroundTag":"invalid-file-permissions","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}