{"record":{"id":"2ac0f7ead29010a6","repo":"slint-ui/slint","slug":"not-a-workspace-can-not-extract-version-info","errorCode":null,"errorMessage":"Not a workspace, can not extract version info.","messagePattern":"Not a workspace, can not extract version info\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/license_headers_check.rs","lineNumber":791,"sourceCode":"struct CargoToml {\n    path: std::path::PathBuf,\n    doc: toml_edit::DocumentMut,\n    edited: bool,\n}\n\nimpl CargoToml {\n    fn new(path: &Path) -> Result<Self> {\n        let source = &std::fs::read_to_string(path).context(\"Error reading file\")?;\n        Ok(Self { doc: source.parse()?, edited: false, path: path.to_path_buf() })\n    }\n\n    fn is_workspace(&self) -> bool {\n        self.doc.as_table().get(\"workspace\").is_some()\n    }\n\n    fn workspace_version(&self) -> Result<&str> {\n        if !self.is_workspace() {\n            Err(anyhow!(\"Not a workspace, can not extract version info.\"))\n        } else {\n            Ok(self\n                .doc\n                .as_table()\n                .get(\"workspace\")\n                .unwrap()\n                .get(\"package\")\n                .unwrap()\n                .get(\"version\")\n                .unwrap()\n                .as_str()\n                .unwrap())\n        }\n    }\n\n    fn package(&self) -> Result<&toml_edit::Table> {\n        if self.is_workspace() {\n            self.doc","sourceCodeStart":773,"sourceCodeEnd":809,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/xtask/src/license_headers_check.rs#L773-L809","documentation":"CargoToml::workspace_version was called on a Cargo.toml that is not a workspace root (it has no [workspace] table), so no workspace.package.version can be extracted. The xtask license/version consistency check uses this to resolve inherited fields in member crates; calling it on a member manifest is an unsupported operation for that file kind.","triggerScenarios":"The check iterates manifests and passes a member crate's Cargo.toml (or any manifest without a [workspace] section) into workspace_version, which requires a workspace root with workspace.package.version.","commonSituations":"Running the xtask check against a single member crate directory instead of the repo root; a refactoring turned a former workspace root into a member; a vendored/example Cargo.toml without [workspace] is included in the manifest walk.","solutions":["Call workspace_version only on manifests where is_workspace() is true; route member manifests through the package() path instead.","Run the xtask license/version check from the workspace root so the root Cargo.toml is used for version extraction.","If this fires unexpectedly, check the manifest for a [workspace] table; add one or fix the file-walk glob that picked the wrong manifest.","Refactor to a single resolver that checks is_workspace() once and returns the version from either workspace.package.version or package.version."],"exampleFix":"// before\nlet version = cargo_toml.workspace_version()?;\n\n// after\nlet version = if cargo_toml.is_workspace() {\n    cargo_toml.workspace_version()?.to_owned()\n} else {\n    cargo_toml.package()?.get(\"version\").and_then(|v| v.as_str()).unwrap_or_default().to_owned()\n};","handlingStrategy":"validation","validationCode":"let version = if cargo_toml.is_workspace() {\n    cargo_toml.workspace_version()?.to_owned()\n} else {\n    // fall back to the member's own package version or look up the root manifest\n    cargo_toml.package()?.get(\"version\")\n        .and_then(|v| v.as_str()).unwrap_or(\"\").to_owned()\n};","typeGuard":"fn is_workspace_root(doc: &toml_edit::DocumentMut) -> bool {\n    doc.as_table().get(\"workspace\").is_some()\n}","tryCatchPattern":"match cargo_toml.workspace_version() {\n    Ok(v) => use_version(v),\n    Err(e) if e.to_string().contains(\"Not a workspace\") => {\n        // manifest is a member: resolve the version from the workspace root instead\n        use_version(&resolve_root_version()?)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Gate workspace_version calls behind is_workspace().","Run xtask checks from the repository/workspace root.","Resolve inherited fields through one helper that handles both manifest kinds.","Review any change that promotes a member manifest to a workspace root."],"tags":["cargo","toml","workspace","xtask"],"backgroundTag":"unsupported-operation","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}