Hmbown/CodeWhale · error · ValidationError

publish package list contains duplicates

Error message

publish package list contains duplicates: {duplicate_crates}

What it means

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.

Solutions

  1. Deduplicate while preserving order, e.g. list(dict.fromkeys(ordered_crates)), in the code that builds the publish list
  2. Review the ordered crate list for repeated entries and remove duplicates
  3. Check the config/CI step that generates the list for accidental double-appends
  4. Re-run the validator after fixing the list

Example fix

// before
ordered = base_crates + new_crates
// after
ordered = list(dict.fromkeys(base_crates + new_crates))
Defensive patterns

Strategy: validation

Validate before calling

ordered = ["codewhale-config", "codewhale-core", "codewhale-tui"]
dups = {n for n in ordered if ordered.count(n) > 1}
if dups:
    raise SystemExit(f"dedupe publish list first: {dups}")

Try / catch

try:
    validate_publish_order(...)
except ValidationError as e:
    if "contains duplicates" in str(e):
        print(f"dedupe the publish list: {e}")
        ordered = list(dict.fromkeys(ordered))

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/b99f75308fb0d4ce. Report an issue: GitHub.

Appendix: source

Thrown at scripts/release/validate-crate-publish-order.py:88

        for package in packages
        if isinstance(package, dict) and isinstance(package.get("id"), str)
    }
    missing_ids = [member for member in members if member not in packages_by_id]
    if missing_ids:
        raise ValidationError(
            "Cargo metadata omits workspace package ids: " + ", ".join(missing_ids)
        )
    return [packages_by_id[member] for member in members]


def validate_order(
    packages: list[dict[str, Any]], ordered_crates: list[str]
) -> tuple[str, dict[str, bool]]:
    duplicate_crates = sorted(
        {name for name in ordered_crates if ordered_crates.count(name) > 1}
    )
    if duplicate_crates:
        raise ValidationError(
            "publish package list contains duplicates: " + ", ".join(duplicate_crates)
        )

    names = [package.get("name") for package in packages]
    if any(not isinstance(name, str) or not name for name in names):
        raise ValidationError("workspace package is missing a name")
    if len(set(names)) != len(names):
        raise ValidationError("Cargo metadata contains duplicate workspace package names")

    versions = sorted({package.get("version") for package in packages})
    if len(versions) != 1 or not isinstance(versions[0], str) or not versions[0]:
        rendered = ", ".join(str(version) for version in versions)
        raise ValidationError(f"workspace packages have mixed versions: {rendered}")

    workspace_by_name = {package["name"]: package for package in packages}
    release_names = sorted(
        name for name in workspace_by_name if name.startswith("codewhale-")
    )

View on GitHub (pinned to 433685b202)