{"record":{"id":"b99f75308fb0d4ce","repo":"Hmbown/CodeWhale","slug":"publish-package-list-contains-duplicates-duplicate-crates","errorCode":null,"errorMessage":"publish package list contains duplicates: {duplicate_crates}","messagePattern":"publish package list contains duplicates: (.+?)","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"scripts/release/validate-crate-publish-order.py","lineNumber":88,"sourceCode":"        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(\n        {name for name in ordered_crates if ordered_crates.count(name) > 1}\n    )\n    if duplicate_crates:\n        raise ValidationError(\n            \"publish package list contains duplicates: \" + \", \".join(duplicate_crates)\n        )\n\n    names = [package.get(\"name\") for package in packages]\n    if any(not isinstance(name, str) or not name for name in names):\n        raise ValidationError(\"workspace package is missing a name\")\n    if len(set(names)) != len(names):\n        raise ValidationError(\"Cargo metadata contains duplicate workspace package names\")\n\n    versions = sorted({package.get(\"version\") for package in packages})\n    if len(versions) != 1 or not isinstance(versions[0], str) or not versions[0]:\n        rendered = \", \".join(str(version) for version in versions)\n        raise ValidationError(f\"workspace packages have mixed versions: {rendered}\")\n\n    workspace_by_name = {package[\"name\"]: package for package in packages}\n    release_names = sorted(\n        name for name in workspace_by_name if name.startswith(\"codewhale-\")\n    )","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/release/validate-crate-publish-order.py#L70-L106","documentation":"validate_order receives the ordered publish crate list and raises this ValidationError if any crate name appears more than once, listing the duplicates sorted. Duplicate publish entries would cause a crate to be validated/published twice, so the list is rejected up front.","triggerScenarios":"The publish-order configuration (ordered_crates, e.g. from release config or CLI args) accidentally lists the same crate name twice — typically from merging two lists, copy-paste, or a scripted append that didn't dedupe.","commonSituations":"CI workflow composing the crate list from two sources (base list + new crates) without deduplication; a maintainer hand-editing the release order and duplicating a line; programmatically generated lists where a filter was applied twice.","solutions":["Deduplicate while preserving order, e.g. list(dict.fromkeys(ordered_crates)), in the code that builds the publish list","Review the ordered crate list for repeated entries and remove duplicates","Check the config/CI step that generates the list for accidental double-appends","Re-run the validator after fixing the list"],"exampleFix":"// before\nordered = base_crates + new_crates\n// after\nordered = list(dict.fromkeys(base_crates + new_crates))","handlingStrategy":"validation","validationCode":"ordered = [\"codewhale-config\", \"codewhale-core\", \"codewhale-tui\"]\ndups = {n for n in ordered if ordered.count(n) > 1}\nif dups:\n    raise SystemExit(f\"dedupe publish list first: {dups}\")","typeGuard":null,"tryCatchPattern":"try:\n    validate_publish_order(...)\nexcept ValidationError as e:\n    if \"contains duplicates\" in str(e):\n        print(f\"dedupe the publish list: {e}\")\n        ordered = list(dict.fromkeys(ordered))","preventionTips":["Build the publish list with an order-preserving dedupe (list(dict.fromkeys(...)))","Avoid concatenating crate lists from multiple sources without deduping","Add a lint/test that asserts the release crate list has unique entries"],"tags":["python","validation","release","config"],"backgroundTag":"invalid-config-value","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}