{"record":{"id":"1f6c3df1d33a02dc","repo":"FuelLabs/sway","slug":"failed-to-serialize-lock-file","errorCode":null,"errorMessage":"failed to serialize lock file: {}","messagePattern":"failed to serialize lock file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"forc-pkg/src/pkg.rs","lineNumber":751,"sourceCode":"            if locked {\n                bail!(\n                    \"The lock file {} needs to be updated (Cause: {}) \\\n                    but --locked was passed to prevent this.\",\n                    lock_path.to_string_lossy(),\n                    cause,\n                );\n            }\n            println_action_green(\n                \"Creating\",\n                &format!(\"a new `Forc.lock` file. (Cause: {cause})\"),\n            );\n            let member_names = manifests\n                .values()\n                .map(|manifest| manifest.project.name.to_string())\n                .collect();\n            crate::lock::print_diff(&member_names, &lock_diff);\n            let string = toml::ser::to_string_pretty(&new_lock)\n                .map_err(|e| anyhow!(\"failed to serialize lock file: {}\", e))?;\n            fs::write(lock_path, string)\n                .map_err(|e| anyhow!(\"failed to write lock file: {}\", e))?;\n            debug!(\"   Created new lock file at {}\", lock_path.display());\n        }\n\n        Ok(plan)\n    }\n\n    /// Produce an iterator yielding all contract dependencies of given node in the order of\n    /// compilation.\n    pub fn contract_dependencies(&self, node: NodeIx) -> impl Iterator<Item = NodeIx> + '_ {\n        let graph = self.graph();\n        let connected: HashSet<_> = Dfs::new(graph, node).iter(graph).collect();\n        self.compilation_order()\n            .iter()\n            .cloned()\n            .filter(move |&n| n != node)\n            .filter(|&n| {","sourceCodeStart":733,"sourceCodeEnd":769,"githubUrl":"https://github.com/FuelLabs/sway/blob/47e5e902faa42baf652dd6a0c88cd23390c1a614/forc-pkg/src/pkg.rs#L733-L769","documentation":"While persisting a freshly generated lock, toml::ser::to_string_pretty(&new_lock) failed; {} is the serde error. The in-memory lock could not be represented as TOML, which the Lock model normally guarantees - so this almost always indicates a bug in forc-pkg or pathological package metadata (e.g. a dependency key that is not TOML-representable) rather than ordinary misconfiguration.","triggerScenarios":"A package or dependency name containing values the TOML serializer rejects; an internal invariant violation producing a non-serializable Lock; essentially only reachable through exotic inputs or a forc-pkg regression.","commonSituations":"Rare in practice; seen with unusual package names or after upgrading to a forc version with a lock-schema bug.","solutions":["Inspect the printed serde error to see which value failed to serialize.","Run 'forc update' to regenerate the lock from scratch.","Simplify unusual package/dependency names and retry.","If it reproduces with a clean state, report it to FuelLabs/sway with the manifest and full error text."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match forc_pkg::pkg::BuildPlan::from_lock_and_manifests(&lock_path, manifests, locked, offline, &ipfs_node) {\n    Ok(plan) => { /* ... */ }\n    Err(e) if e.to_string().starts_with(\"failed to serialize lock file\") => {\n        // not user-fixable config: capture state and report to FuelLabs/sway\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep package and dependency names to plain alphanumeric characters, '-' and '_'.","Regenerate locks with 'forc update' rather than carrying them across forc upgrades."],"tags":["lock-file","serialization","toml","upstream-bug"],"backgroundTag":null,"analyzedSha":"47e5e902faa42baf652dd6a0c88cd23390c1a614","analyzedAt":"2026-08-16T07:57:45.555Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}