rohitg00/ai-engineering-from-scratch · error · ValueError

category {cat} has {per_cat[cat]} fixtures, need >= {MIN_PER

Error message

category {cat} has {per_cat[cat]} fixtures, need >= {MIN_PER_CATEGORY}

What it means

Error "category {cat} has {per_cat[cat]} fixtures, need >= {MIN_PER_CATEGORY}" thrown in rohitg00/ai-engineering-from-scratch.

Source

Thrown at phases/19-capstone-projects/82-jailbreak-taxonomy/code/main.py:114

        if not self._records:
            raise ValueError("empty fixture corpus")
        seen_ids: set[str] = set()
        per_cat: defaultdict[str, int] = defaultdict(int)
        for f in self._records:
            if not f.prompt.strip():
                raise ValueError(f"fixture {f.id} has empty prompt")
            if f.id in seen_ids:
                raise ValueError(f"duplicate fixture id: {f.id}")
            seen_ids.add(f.id)
            lo, hi = SEVERITY_RANGE
            if not (lo <= f.severity <= hi):
                raise ValueError(f"fixture {f.id} severity {f.severity} out of {SEVERITY_RANGE}")
            if f.category not in CATEGORIES:
                raise ValueError(f"fixture {f.id} unknown category {f.category}")
            per_cat[f.category] += 1
        for cat in CATEGORIES:
            if per_cat[cat] < MIN_PER_CATEGORY:
                raise ValueError(f"category {cat} has {per_cat[cat]} fixtures, need >= {MIN_PER_CATEGORY}")

    def all(self) -> list[Fixture]:
        return list(self._records)

    def by_category(self) -> dict[str, list[Fixture]]:
        grouped: dict[str, list[Fixture]] = {c: [] for c in CATEGORIES}
        for f in self._records:
            grouped[f.category].append(f)
        return grouped

    def stats(self) -> dict[str, object]:
        per_cat = {c: 0 for c in CATEGORIES}
        sev_hist = {s: 0 for s in range(SEVERITY_RANGE[0], SEVERITY_RANGE[1] + 1)}
        for f in self._records:
            per_cat[f.category] += 1
            sev_hist[f.severity] += 1
        return {
            "total": len(self._records),

View on GitHub (pinned to 39ea8a1c6d)

When it happens

Trigger: Thrown at phases/19-capstone-projects/82-jailbreak-taxonomy/code/main.py:114 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26). Data as JSON: /api/errors/f1976079a4930f2c. Report an issue: GitHub.