{"record":{"id":"922dcaa96c388eff","repo":"sxyazi/yazi","slug":"not-a-url","errorCode":null,"errorMessage":"not a URL","messagePattern":"not a URL","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-shared/src/data/data.rs","lineNumber":187,"sourceCode":"\ttype Error = anyhow::Error;\n\n\tfn try_from(value: Data) -> Result<Self, Self::Error> {\n\t\tmatch value {\n\t\t\tData::Dict(d) => Ok(d),\n\t\t\t_ => bail!(\"not a dict\"),\n\t\t}\n\t}\n}\n\nimpl TryFrom<Data> for UrlCow<'static> {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(value: Data) -> Result<Self, Self::Error> {\n\t\tmatch value {\n\t\t\tData::String(s) => s.try_into(),\n\t\t\tData::Url(u) => Ok(u.into()),\n\t\t\tData::Bytes(b) => b.try_into(),\n\t\t\t_ => bail!(\"not a URL\"),\n\t\t}\n\t}\n}\n\nimpl TryFrom<Data> for UrlBuf {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(value: Data) -> Result<Self, Self::Error> { UrlCow::try_from(value).map(Into::into) }\n}\n\nimpl<'a> TryFrom<&'a Data> for UrlCow<'a> {\n\ttype Error = anyhow::Error;\n\n\tfn try_from(value: &'a Data) -> Result<Self, Self::Error> {\n\t\tmatch value {\n\t\t\tData::String(s) => Self::try_from(&**s),\n\t\t\tData::Url(u) => Ok(u.into()),\n\t\t\tData::Bytes(b) => b.as_slice().try_into(),","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/sxyazi/yazi/blob/5f901b886b14de1f17460b6e52e9de5d67f8aba9/yazi-shared/src/data/data.rs#L169-L205","documentation":"Thrown by `TryFrom<Data> for UrlCow<'static>` when the `Data` value cannot be interpreted as a URL. The impl accepts `String`, `Url`, and `Bytes` variants (parsing/interpreting each as a URL) and bails \"not a URL\" for every other variant.","triggerScenarios":"`UrlCow::try_from(data)` where `data` is e.g. `Data::Bool`, `Data::Integer`, `Data::Number`, or `Data::Dict`.","commonSituations":"Plugin messages or fetch results where a field is expected to hold a file path/URL but contains a number or table — often a config key mix-up or an API change where a string field became structured data.","solutions":["Verify the source produced one of String/Url/Bytes and fix the producer.","Match the variant and build a `UrlBuf`/`UrlCow` only in the supported cases.","If the value is a Path variant, convert via the path API (`into_url()`) instead of Data's TryFrom."],"exampleFix":"// before\nlet url: UrlCow = data.try_into()?;\n// after\nlet url: UrlCow = match data {\n    d @ (Data::String(_) | Data::Url(_) | Data::Bytes(_)) => d.try_into()?,\n    Data::Path(p) => p.into_url().into(),\n    other => bail!(\"not a URL: {other:?}\"),\n};","handlingStrategy":"type-guard","validationCode":"fn is_url_like(data: &Data) -> bool {\n    matches!(data, Data::String(_) | Data::Url(_) | Data::Bytes(_))\n}","typeGuard":"fn as_url(data: &Data) -> Option<UrlCow<'static>> {\n    match data {\n        Data::String(s) => s.to_string().try_into().ok(),\n        Data::Url(u) => Some(u.clone().into()),\n        _ => None,\n    }\n}","tryCatchPattern":"match UrlCow::try_from(data) {\n    Ok(url) => use_url(url),\n    Err(e) => log::warn!(\"expected URL payload: {e}\"),\n}","preventionTips":["Produce URL fields as `Data::Url` or `Data::String` consistently.","Handle `Data::Path` via the path-to-URL API rather than Data TryFrom.","Validate payload keys against the expected schema in plugin code."],"tags":["rust","type-conversion","url"],"backgroundTag":"type-conversion-failed","analyzedSha":"5f901b886b14de1f17460b6e52e9de5d67f8aba9","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}