Hmbown/CodeWhale · error · ValueError

could not locate PENDING_GROUPS in

Error message

could not locate PENDING_GROUPS in {path}

What it means

load_pending_groups in scripts/check-command-migration-manifest.py extracts the PENDING_GROUPS constant (a pub(crate) &[&str] array) from a Rust source file using a regex. It raises ValueError when the regex finds no match, meaning the PENDING_GROUPS declaration is absent, was renamed, or its syntax no longer matches the expected pattern.

Solutions

  1. Confirm the path points at the Rust file that currently owns PENDING_GROUPS
  2. Restore or re-add the PENDING_GROUPS declaration in the expected pub(crate) const form
  3. If the declaration was intentionally removed (migration done), update or retire the checker step rather than the source
  4. Adjust the regex if the constant's syntax legitimately changed (e.g. visibility or type)

Example fix

// before (checker fails: no constant found)
// (constant deleted)
// after
pub(crate) const PENDING_GROUPS: &[&str] = &[
    "some_pending_command",
];
Defensive patterns

Strategy: validation

Validate before calling

import re, pathlib
src = pathlib.Path(path).read_text()
assert re.search(r"pub\(crate\)\s+const\s+PENDING_GROUPS\s*:\s*&\[&str\]", src), "PENDING_GROUPS declaration missing"

Try / catch

try:
    pending = load_pending_groups(path)
except ValueError as exc:
    print(f"manifest checker cannot proceed: {exc}")
    sys.exit(1)

Prevention

When it happens

Trigger: Running the migration-manifest checker against a Rust file at {path} that no longer contains a declaration matching pub(crate) const PENDING_GROUPS: &[&str] = &[...]; — e.g. the constant was removed after the migration completed, renamed, made public (pub instead of pub(crate)), or reformatted with comments/attributes between the tokens.

Common situations: The migration frontier was emptied and the constant deleted; a refactor changed the type (e.g. to a Vec or added a type alias); rustfmt introduced line breaks the DOTALL regex still expects to bridge but attribute lines broke the signature; checker run against the wrong file path.

Understand the failure class

Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at scripts/check-command-migration-manifest.py:473

    violations.extend(validate_frontier(topology, doc.get("frontier", [])))
    return violations


def load_topology(path: Path = TOPOLOGY_PATH) -> dict:
    with path.open(encoding="utf-8") as fh:
        return json.load(fh)


def load_pending_groups(path: Path = CONTRACT_PATH) -> list[str]:
    """Read the TUI frontier projection from `PENDING_GROUPS` fail-closed."""
    source = path.read_text(encoding="utf-8")
    match = re.search(
        r"pub\(crate\)\s+const\s+PENDING_GROUPS\s*:\s*&\[&str\]\s*=\s*&\[(.*?)\];",
        source,
        re.DOTALL,
    )
    if match is None:
        raise ValueError(f"could not locate PENDING_GROUPS in {path}")
    body = match.group(1)
    stripped = re.sub(r'"(?:\\.|[^"\\])*"', "", body)
    if re.fullmatch(r"[\s,]*", stripped) is None:
        raise ValueError("PENDING_GROUPS may contain string literals only")
    return re.findall(r'"((?:\\.|[^"\\])*)"', body)


def validate_pending_projection(doc: dict, pending: list[str]) -> list[ManifestViolation]:
    if pending != doc.get("frontier"):
        return [ManifestViolation(
            "frontier-projection",
            "PENDING_GROUPS",
            f"TUI projection {pending!r} does not equal JSON frontier {doc.get('frontier')!r}",
        )]
    return []


def load_topology_at_ref(ref: str, root: Path = REPO_ROOT) -> dict | None:

View on GitHub (pinned to 433685b202)