Skip to content

Report generation crashes on empty categorical histograms #905

Description

@andreatnvidia

Priority Level

Medium (Annoying but has workaround)

Describe the bug

DatasetProfilerResults accepts categorical histogram data with empty categories and counts lists, but to_report() crashes while rendering it:

ValueError: max() arg is an empty sequence

This prevents report generation for a schema-valid analysis result with no categorical observations.

Steps/Code to reproduce bug

from pathlib import Path

from data_designer.config.analysis.dataset_profiler import DatasetProfilerResults


document = {
    "num_records": 1,
    "target_num_records": 1,
    "column_statistics": [
        {
            "column_type": "general",
            "column_name": "text",
            "num_records": 1,
            "num_null": 0,
            "num_unique": 1,
            "pyarrow_dtype": "string",
            "simple_dtype": "str",
        }
    ],
    "column_profiles": [
        {
            "column_name": "quality",
            "summaries": {
                "helpfulness": {
                    "score_name": "helpfulness",
                    "summary": "No observations",
                    "score_samples": [],
                }
            },
            "score_distributions": {
                "scores": {"helpfulness": []},
                "reasoning": {"helpfulness": []},
                "distribution_types": {"helpfulness": "categorical"},
                "distributions": {"helpfulness": "--"},
                "histograms": {
                    "helpfulness": {"categories": [], "counts": []},
                },
            },
        }
    ],
}

results = DatasetProfilerResults.model_validate(document)
results.to_report(Path("report.html"))

Model validation succeeds, then report rendering raises ValueError: max() arg is an empty sequence.

Expected behavior

An empty categorical histogram should render an empty-state placeholder, or it should be rejected during model validation with a clear validation error. to_report() should not raise an exception for an accepted input.

Agent Diagnostic / Prior Investigation

Reproduced on the current main branch. A histogram containing one category and one count renders successfully as a negative control.

CategoricalHistogramData in packages/data-designer-config/src/data_designer/config/analysis/column_statistics.py allows empty lists. The report path converts those lists into an empty mapping and passes it to create_rich_histogram_table() in packages/data-designer-config/src/data_designer/config/utils/visualization.py, which calls max(data.values()) without checking whether the mapping is empty.

The issue tracker was searched for CategoricalHistogramData, empty categorical histograms, and max() arg is an empty sequence; no matching issue was found.

Additional context

Regression coverage should exercise the public DatasetProfilerResults.to_report() method with empty categorical histogram data. Handling the empty state in the renderer would also make the shared visualization helper more robust.

Checklist

  • I reproduced this issue or provided a minimal example
  • I searched the docs/issues myself, or had my agent do so
  • If I used an agent, I included its diagnostics above

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions