{"record":{"id":"6869dad1bf6e322a","repo":"swc-project/swc","slug":"expected-url-or-function-with-url-or-src-name","errorCode":null,"errorMessage":"Expected url or function (with 'url' or 'src' name) token","messagePattern":"Expected url or function \\(with 'url' or 'src' name\\) token","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_css_parser/src/parser/values_and_units/mod.rs","lineNumber":2594,"sourceCode":"                value,\n                raw: Some(raw),\n            }),\n            _ => {\n                unreachable!()\n            }\n        }\n    }\n}\n\nimpl<I> Parse<Url> for Parser<I>\nwhere\n    I: ParserInput,\n{\n    fn parse(&mut self) -> PResult<Url> {\n        let span = self.input.cur_span();\n\n        if !is_one_of!(self, Url, Function) {\n            return Err(Error::new(\n                span,\n                ErrorKind::Expected(\"url or function (with 'url' or 'src' name) token\"),\n            ));\n        }\n\n        match bump!(self) {\n            Token::Url { value, raw } => {\n                let name_length = raw.0.len() as u32;\n                let name = Ident {\n                    span: Span::new(span.lo, span.lo + BytePos(name_length)),\n                    value: self.input.atom(\"url\"),\n                    raw: Some(raw.0),\n                };\n                let value = Some(Box::new(UrlValue::Raw(UrlValueRaw {\n                    span: Span::new(span.lo + BytePos(name_length + 1), span.hi - BytePos(1)),\n                    value,\n                    raw: Some(raw.1),\n                })));","sourceCodeStart":2576,"sourceCodeEnd":2612,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_css_parser/src/parser/values_and_units/mod.rs#L2576-L2612","documentation":"Fired while parsing a Url: the current token was neither a url(...) token nor a Function token, so no URL value could be produced. This `if !is_one_of!(self, Url, Function)` check is a validation guard; input at fault is a url-required context (e.g. @import, background-image) receiving a bare ident or string instead of `url(...)`.","triggerScenarios":"Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:2594 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use url(...) or src(...) syntax with a valid URL argument","Quote the URL if it contains special characters"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}