fix: validate builder row output type#350
Open
Costin10 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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
listtype check invalidate_rowsand raiseValidationErroron 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}) |
76592df to
91275e4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #326
Tests