{"record":{"id":"7076978fd191d8a8","repo":"FuelLabs/sway","slug":"failed-to-parse-dependency","errorCode":null,"errorMessage":"failed to parse dependency \"{}\": {}","messagePattern":"failed to parse dependency \"(.+?)\": (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"forc-pkg/src/lock.rs","lineNumber":220,"sourceCode":"            // If `pkg.contract_dependencies` is None, we will be collecting an empty list of\n            // contract_deps so that we will omit them during edge adding phase\n            let contract_deps = pkg\n                .contract_dependencies\n                .as_ref()\n                .into_iter()\n                .flatten()\n                .map(|contract_dep| (contract_dep, UnparsedDepKind::Contract));\n            // If `pkg.dependencies` is None, we will be collecting an empty list of\n            // lib_deps so that we will omit them during edge adding phase\n            let lib_deps = pkg\n                .dependencies\n                .as_ref()\n                .into_iter()\n                .flatten()\n                .map(|lib_dep| (lib_dep, UnparsedDepKind::Library));\n            for (dep_line, dep_kind) in lib_deps.chain(contract_deps) {\n                let (dep_name, dep_key, dep_salt) = parse_pkg_dep_line(dep_line)\n                    .map_err(|e| anyhow!(\"failed to parse dependency \\\"{}\\\": {}\", dep_line, e))?;\n                let dep_node = pkg_to_node\n                    .get(dep_key)\n                    .copied()\n                    .ok_or_else(|| anyhow!(\"found dep {} without node entry in graph\", dep_key))?;\n                let dep_name = dep_name.unwrap_or(&graph[dep_node].name).to_string();\n                let dep_kind = match dep_kind {\n                    UnparsedDepKind::Library => DepKind::Library,\n                    UnparsedDepKind::Contract => {\n                        let dep_salt = dep_salt.unwrap_or_default();\n                        DepKind::Contract { salt: dep_salt }\n                    }\n                };\n                let dep_edge = Edge::new(dep_name, dep_kind);\n                graph.update_edge(node, dep_node, dep_edge);\n            }\n        }\n\n        Ok(graph)","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/lock.rs#L202-L238","documentation":"During Lock::to_graph, each package's dependency lines ('<name> <source>' or '(<name> <source>) <salt>') are parsed by parse_pkg_dep_line. A syntax error inside one line produces this message quoting the exact offending line, so the line itself tells you what is wrong. It signals lock-file corruption, not a missing package or network issue.","triggerScenarios":"A dependency line under a package entry in Forc.lock that does not parse: missing source after the name, stray characters, half-deleted merge-conflict text, or a salt part that breaks the expected bracket layout before the salt itself is validated.","commonSituations":"Manual edits to Forc.lock; bad merge-conflict resolution; tools that reformat the lock file; mismatched forc versions writing subtly different line formats.","solutions":["Delete Forc.lock and run forc build to regenerate every dependency line from Forc.toml.","If editing is required, match the exact grammar: (name source) salt for contract deps with salt, name source otherwise.","Adopt a repo convention to regenerate the lock after dependency changes instead of merging it."],"exampleFix":"# before (Forc.lock)\ndependencies = [\n  \"auth lib git+https://github.com/x/auth#<<<<<<< HEAD\", # merge garbage\n]\n\n# after - regenerate: rm Forc.lock && forc build","handlingStrategy":"fallback","validationCode":"// Rust, pre-validate each dependency line before graph construction:\nfn dep_lines_ok(lock: &Lock) -> bool {\n    lock.package.iter().all(|p| p.dependencies.as_ref()\n        .into_iter().flatten().all(|l| parse_pkg_dep_line(l).is_ok()))\n}","typeGuard":null,"tryCatchPattern":"// Parse failure of a derived artifact -> regenerate:\nmatch lock.to_graph() {\n    Ok(g) => { /* ... */ }\n    Err(_) => { fs::remove_file(lock_path).ok(); /* re-resolve from Forc.toml */ }\n}","preventionTips":["Treat Forc.lock dependency lines as machine-written only.","After merges touching Forc.lock, delete it and rebuild instead of merging content.","Keep dependency declarations in Forc.toml as the single source of truth."],"tags":["forc","forc-pkg","lockfile","parsing"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}