{"record":{"id":"254af54cc0a8a8a8","repo":"sxyazi/yazi","slug":"target-url-must-be-absolute","errorCode":null,"errorMessage":"Target URL must be absolute","messagePattern":"Target URL must be absolute","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"yazi-actor/src/mgr/displace_do.rs","lineNumber":28,"sourceCode":"pub struct DisplaceDo;\n\nimpl Actor for DisplaceDo {\n\ttype Form = DisplaceDoForm;\n\n\tconst NAME: &str = \"displace_do\";\n\n\tfn act(cx: &mut Ctx, Self::Form { opt }: Self::Form) -> Result<Data> {\n\t\tif cx.cwd() != opt.from {\n\t\t\tsucc!()\n\t\t}\n\n\t\tlet to = match opt.to {\n\t\t\tOk(url) => url,\n\t\t\tErr(e) => return act!(mgr:update_files, cx, FilesOp::IOErr(opt.from, e)),\n\t\t};\n\n\t\tif !to.is_absolute() {\n\t\t\tbail!(\"Target URL must be absolute\");\n\t\t} else if let Some(hovered) = cx.hovered()\n\t\t\t&& let Ok(url) = to.try_join(hovered.urn())\n\t\t{\n\t\t\tact!(mgr:reveal, cx, (url, CdSource::Displace))\n\t\t} else {\n\t\t\tact!(mgr:cd, cx, (to, CdSource::Displace))\n\t\t}\n\t}\n}\n","sourceCodeStart":10,"sourceCodeEnd":38,"githubUrl":"https://github.com/sxyazi/yazi/blob/441b332de8b8800e70784cfbfb75369ab51ed9dd/yazi-actor/src/mgr/displace_do.rs#L10-L38","documentation":"Raised by TryFrom<u16> for ChaMode (yazi-fs/src/cha/mode.rs:66) when bitflags' from_bits rejects a raw mode value because it contains bits outside the declared ChaMode flag set. The declared flags cover type bits (0xF000), special bits (SUID/SGID/sticky), and rwx permission bits, which together occupy all 16 bits, so in practice from_bits only fails for values with extension/reserved bits a future format might introduce; a wrong file-type nibble instead produces the sibling `invalid file type` error on line 75.","triggerScenarios":"Calling ChaMode::try_from(value) with a hand-composed u16 that sets undefined bits (e.g. bits reserved by a new stat format or a corrupted mode read over DDS); deserializing a mode from an external/remote source whose encoding includes extra flag bits; note the distinct `invalid file type` error occurs when the type nibble is 0/unknown or a non-mapped combination.","commonSituations":"Interop code marshalling st_mode between platforms or over the network with a different bit layout; custom filesystems/FUSE reporting unusual mode bits; version skew between a yazi instance serializing Cha and an older one parsing it.","solutions":["Mask the incoming value to the known bit set before converting (value & 0xFFFF with only defined flags, e.g. strip extension bits)","Fix the producer to emit a mode within the documented layout (type nibble must be one of T_FILE/T_DIR/T_LINK/T_BLOCK/T_CHAR/T_SOCK/T_FIFO)","If the type nibble is the problem (error text says `invalid file type`), map unknown types to ChaType::Unknown via from_bare instead of try_from","Align versions on both ends when Cha data crosses processes"],"exampleFix":"// before\nlet mode = ChaMode::try_from(raw_mode)?;\n// after\nlet mode = ChaMode::try_from(raw_mode & 0o7777 | type_bits)?; // strip undefined bits\n// or for unknown types:\nlet mode = ChaMode::from_bare(ChaType::Unknown);","handlingStrategy":"validation","validationCode":"// Rust: check the type nibble and mask unknown bits before converting\nconst T_MASK: u16 = 0xF000;\nlet masked = value & 0xFFFF;\nlet type_ok = matches!(masked & T_MASK,\n    0x8000 | 0x4000 | 0xA000 | 0x6000 | 0x2000 | 0xC000 | 0x1000);\nlet mode = if type_ok { ChaMode::try_from(masked)? } else { ChaMode::from_bare(ChaType::Unknown) };","typeGuard":"// Rust\nfn is_known_mode(v: u16) -> bool {\n    ChaMode::from_bits(v).is_some_and(|m| matches!(m & ChaMode::T_MASK,\n        ChaMode::T_FILE | ChaMode::T_DIR | ChaMode::T_LINK | ChaMode::T_BLOCK\n        | ChaMode::T_CHAR | ChaMode::T_SOCK | ChaMode::T_FIFO))\n}","tryCatchPattern":"// Rust: degrade to Unknown instead of failing\nlet mode = ChaMode::try_from(raw).unwrap_or_else(|_| ChaMode::from_bare(ChaType::Unknown));","preventionTips":["Never hand-build mode bits; derive them from std::fs::metadata","Mask external modes to the documented layout before try_from","Map unrecognized file types to ChaType::Unknown rather than erroring","Version-align processes that serialize Cha data"],"tags":["rust","bitflags","file-metadata","parsing","yazi"],"backgroundTag":"invalid-bitmask-value","analyzedSha":"441b332de8b8800e70784cfbfb75369ab51ed9dd","analyzedAt":"2026-08-19T05:27:26.468Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}