Hmbown/CodeWhale · error · ValidationError

workspace package is missing a name

Error message

workspace package is missing a name

What it means

validate_order extracts each workspace package's 'name' and raises this ValidationError if any package lacks a non-empty string name. Without names, crates cannot be matched against the ordered publish list.

Solutions

  1. Regenerate metadata with cargo metadata --locked --format-version 1 --no-deps so every package has a name
  2. Fix the fixture/transformation step that strips or renames the 'name' field
  3. Ensure each workspace member's Cargo.toml defines a non-empty [package] name
  4. Validate the metadata file with jq/python before running the validator

Example fix

// before (trimmed entry)
{"id": "x", "version": "0.1.0"}
// after
{"id": "x", "name": "codewhale-core", "version": "0.1.0"}
Defensive patterns

Strategy: validation

Validate before calling

import json
m = json.load(open("cargo-metadata.json"))
bad = [p for p in m.get("packages", []) if not isinstance(p.get("name"), str) or not p.get("name")]
if bad:
    raise SystemExit(f"packages missing names: {len(bad)}; regenerate metadata")

Type guard

def has_name(p) -> bool:
    return isinstance(p, dict) and isinstance(p.get("name"), str) and bool(p["name"])

Try / catch

try:
    validate_publish_order(metadata_file)
except ValidationError as e:
    if "missing a name" in str(e):
        print("metadata entries lack 'name'; use unmodified cargo metadata output")

Prevention

When it happens

Trigger: A package entry in cargo metadata has no 'name' field or an empty/None name — only possible with malformed, hand-edited, or mocked metadata, since real cargo metadata always includes names.

Common situations: Hand-trimmed metadata files that dropped the name key; test fixtures built incorrectly; a tool version or transformation step that renamed/removed the field.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

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

            "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-")
    )
    ordered_set = set(ordered_crates)
    missing = sorted(set(release_names) - ordered_set)
    extra = sorted(ordered_set - set(release_names))
    if missing or extra:
        messages = []
        if missing:

View on GitHub (pinned to 433685b202)