{"record":{"id":"242f0d0b550f54d6","repo":"rust-lang/cargo","slug":"unrecognized-dependency-entry-format-for-key","errorCode":null,"errorMessage":"Unrecognized` dependency entry format for `{key}","messagePattern":"Unrecognized` dependency entry format for `(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/workspace/editor/dependency.rs","lineNumber":380,"sourceCode":"            };\n\n            let optional = table.get(\"optional\").and_then(|v| v.as_bool());\n            let public = table.get(\"public\").and_then(|v| v.as_bool());\n\n            let dep = Self {\n                name,\n                optional,\n                public,\n                features,\n                default_features,\n                inherited_features: None,\n                source: Some(source),\n                registry,\n                rename,\n            };\n            Ok(dep)\n        } else {\n            anyhow::bail!(\"Unrecognized` dependency entry format for `{key}\");\n        }\n    }\n\n    /// Get the dependency name as defined in the manifest,\n    /// that is, either the alias (rename field if Some),\n    /// or the official package name (name field).\n    pub fn toml_key(&self) -> &str {\n        self.rename().unwrap_or(&self.name)\n    }\n\n    /// Convert dependency to TOML.\n    ///\n    /// Returns a tuple with the dependency's name and either the version as a\n    /// `String` or the path/git repository as an `InlineTable`.\n    /// (If the dependency is set as `optional` or `default-features` is\n    /// explicitly set, an `InlineTable` is returned in any case.)\n    ///\n    /// # Panic","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/rust-lang/cargo/blob/eb98b54bc9f3c74519f43d066cb3fd02ebc88df0/src/workspace/editor/dependency.rs#L362-L398","documentation":"Thrown by the manifest editor dependency parser when the dependency item is neither a TOML string nor a table-like value. The from_toml method first tries item.as_str() then item.as_table_like(); if both return None it reaches the final else branch. Note the message itself contains a stray backtick ('Unrecognized`') which is a bug in the format string.","triggerScenarios":"Calling Dependency::from_toml where the toml_edit::Item is an integer, float, boolean, array, or an invalid/non-table/non-string node. This is structurally invalid for a dependency entry which must be either a version string or a detailed table.","commonSituations":"A programmatic manifest edit inserts a wrong toml_edit::Item type into a dependency slot. Corrupt or hand-written TOML where a dependency value is a bare number or boolean. A serialization bug that writes a scalar where a table or string was expected.","solutions":["Ensure the dependency item is a TOML string (simple version) or a TOML table (detailed spec).","If building the manifest programmatically, validate the toml_edit::Item type before assignment.","Inspect the raw Cargo.toml at the named key and replace the invalid value with a proper dependency spec."],"exampleFix":"# before (invalid)\n[dependencies]\nserde = 1\n\n# after\n[dependencies]\nserde = \"1\"","handlingStrategy":"type-guard","validationCode":"fn dependency_item_is_valid(item: &toml_edit::Item) -> bool {\n    item.is_str() || item.is_table_like()\n}","typeGuard":"fn is_valid_dependency_item(item: &toml_edit::Item) -> bool {\n    item.as_str().is_some() || item.as_table_like().is_some()\n}","tryCatchPattern":null,"preventionTips":["Before inserting a toml_edit::Item into a dependencies table, assert it is a string or table.","When programmatically editing manifests, use toml_edit::Item::value to construct valid entries.","Validate manifest structure with `cargo metadata` after generation."],"tags":["cargo","manifest","dependencies","toml","editor","invalid-type"],"backgroundTag":null,"analyzedSha":"eb98b54bc9f3c74519f43d066cb3fd02ebc88df0","analyzedAt":"2026-08-11T17:42:36.556Z","contentChangedAt":"2026-08-11T17:42:36.556Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}