Skip to content

fix: validate builder row output type#350

Open
Costin10 wants to merge 1 commit into
Wat-Street:mainfrom
Costin10:fix/validate-builder-output
Open

fix: validate builder row output type#350
Costin10 wants to merge 1 commit into
Wat-Street:mainfrom
Costin10:fix/validate-builder-output

Conversation

@Costin10

@Costin10 Costin10 commented Jun 5, 2026

Copy link
Copy Markdown

Summary

  • add a clear ValidationError when builder output is not a list of rows
  • cover None and dict outputs in validate_rows regression tests
  • update the backend spec line for builder output validation

Closes #326

Tests

  • uv run pytest builders/server/tests/core/runtime/test_validator.py
  • uv run pytest builders/server/tests/core/runtime
  • uvx ruff check builders/server/core/runtime/validator.py builders/server/tests/core/runtime/test_validator.py
  • git diff --check

Copilot AI review requested due to automatic review settings June 5, 2026 23:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an explicit runtime check that builder output is a list before validating rows, and documents/tests the new behavior.

Changes:

  • Add a list type check in validate_rows and raise ValidationError on non-list output.
  • Add pytest coverage for rejecting non-list builder output.
  • Update backend spec to document the “must be a list of row dicts” requirement.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
dev-docs/SPEC-backend.md Documents that builder output must be a list, failing fast before per-row checks.
builders/server/tests/core/runtime/test_validator.py Adds tests ensuring non-list outputs raise ValidationError.
builders/server/core/runtime/validator.py Implements the runtime guard for non-list builder outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +26 to 34
def validate_rows(data_list: object, schema: dict[str, SchemaType]) -> None:
"""Validate each dict in a list against the declared schema."""
if not isinstance(data_list, list):
raise ValidationError(
f"Builder output expected a list of rows, got '{type(data_list).__name__}'"
)

for data in data_list:
validate(data, schema)


def validate_rows(data_list: list[dict], schema: dict[str, SchemaType]) -> None:
def validate_rows(data_list: object, schema: dict[str, SchemaType]) -> None:
Comment on lines +85 to +89
@pytest.mark.parametrize("data", [None, {}])
def test_validate_rows_rejects_non_list_output(data: object) -> None:
"""Builder output must be a list of row dictionaries."""
with pytest.raises(ValidationError, match="expected a list of rows"):
validate_rows(data, {"ticker": SchemaType.STR})
@Costin10 Costin10 force-pushed the fix/validate-builder-output branch from 76592df to 91275e4 Compare June 5, 2026 23:28
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.

good first issue: validate builder output type in validate_rows

2 participants