{"record":{"id":"ae3d913892ac3d73","repo":"Hmbown/CodeWhale","slug":"cargo-metadata-must-contain-workspace-members-and","errorCode":null,"errorMessage":"Cargo metadata must contain workspace_members and packages lists","messagePattern":"Cargo metadata must contain workspace_members and packages lists","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"scripts/release/validate-crate-publish-order.py","lineNumber":66,"sourceCode":"            raise ValidationError(\n                f\"cargo metadata failed with exit code {process.returncode}{suffix}\"\n            )\n        raw = process.stdout\n\n    try:\n        metadata = json.loads(raw)\n    except json.JSONDecodeError as error:\n        raise ValidationError(f\"Cargo metadata is not valid JSON: {error}\") from error\n    if not isinstance(metadata, dict):\n        raise ValidationError(\"Cargo metadata root must be an object\")\n    return metadata\n\n\ndef workspace_packages(metadata: dict[str, Any]) -> list[dict[str, Any]]:\n    members = metadata.get(\"workspace_members\")\n    packages = metadata.get(\"packages\")\n    if not isinstance(members, list) or not isinstance(packages, list):\n        raise ValidationError(\"Cargo metadata must contain workspace_members and packages lists\")\n\n    packages_by_id = {\n        package.get(\"id\"): package\n        for package in packages\n        if isinstance(package, dict) and isinstance(package.get(\"id\"), str)\n    }\n    missing_ids = [member for member in members if member not in packages_by_id]\n    if missing_ids:\n        raise ValidationError(\n            \"Cargo metadata omits workspace package ids: \" + \", \".join(missing_ids)\n        )\n    return [packages_by_id[member] for member in members]\n\n\ndef validate_order(\n    packages: list[dict[str, Any]], ordered_crates: list[str]\n) -> tuple[str, dict[str, bool]]:\n    duplicate_crates = sorted(","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/release/validate-crate-publish-order.py#L48-L84","documentation":"workspace_packages() requires both 'workspace_members' and 'packages' to be present as JSON arrays in the metadata; one of them was missing or not a list. Without both, member ids cannot be mapped to package records.","triggerScenarios":"A fixture built from a partial copy of cargo metadata that omits one key; a key whose value is null, an object, or a string; metadata from a hypothetical future format-version that renames the keys.","commonSituations":"Hand-minimized test fixtures for the validator that dropped a required key.","solutions":["Regenerate the metadata fixture with the exact command the script uses: cargo metadata --locked --format-version 1 --no-deps","If editing by hand, ensure both workspace_members and packages are JSON arrays at the root"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def has_required_lists(metadata: dict) -> bool:\n    return isinstance(metadata.get(\"workspace_members\"), list) and isinstance(metadata.get(\"packages\"), list)","tryCatchPattern":null,"preventionTips":["Pin fixtures to output of the same cargo version the CI uses","When trimming fixtures for size, keep both required arrays intact"],"tags":["json","validation","cargo","release","python"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}