Skip to content

Validate SweepData.from_dict() results entries are dicts, raise HWQueueLoaderError#124

Closed
Copilot wants to merge 2 commits intoprosenj_cli_hq_eval_report_phase_1from
copilot/sub-pr-98-another-one
Closed

Validate SweepData.from_dict() results entries are dicts, raise HWQueueLoaderError#124
Copilot wants to merge 2 commits intoprosenj_cli_hq_eval_report_phase_1from
copilot/sub-pr-98-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

SweepData.from_dict() iterated over data["results"] assuming all entries were dicts. Non-dict entries (strings, ints, lists, None) caused AttributeError from .get() to escape rather than a meaningful HWQueueLoaderError.

Changes

  • hwqueue_loader.py — Replace the list comprehension in SweepData.from_dict() with an explicit loop that validates each entry with isinstance(r, dict), raising HWQueueLoaderError with the entry index and actual type on failure:
# Before — AttributeError escapes for non-dict entries
results = [SingleRunData.from_dict(r) for r in data.get("results", [])]

# After — clear HWQueueLoaderError with index and type
for i, r in enumerate(raw_results):
    if not isinstance(r, dict):
        raise HWQueueLoaderError(
            f"Invalid schema: 'results[{i}]' must be a dict, got {type(r).__name__}"
        )
    results.append(SingleRunData.from_dict(r))
  • tests/test_hwqueue_loader.py (new) — 11 tests covering: valid entries, empty/missing results, non-dict entry types (str, int, list, None), correct index in error message, no AttributeError escaping, and integration through HWQueueLoader.load_sweep() / load_auto().

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ueLoaderError

Co-authored-by: prosenjitdhole <239307697+prosenjitdhole@users.noreply.github.com>
Copilot AI changed the title [WIP] Update json loader for configuration changes based on review feedback Validate SweepData.from_dict() results entries are dicts, raise HWQueueLoaderError Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants