-
Notifications
You must be signed in to change notification settings - Fork 2
fix: Add validation for manifest streams structure to prevent AttributeError #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…teError - Add defensive validation in run_connector_readiness_test_report to check that all streams in the manifest are properly formatted dicts - Raise clear ValueError with actionable message when streams field contains invalid entries (e.g., strings instead of stream definition objects) - Add test case to verify the validation provides clear error messages - Fixes issue where AI-generated manifests with malformed streams field caused AttributeError: 'str' object has no attribute 'get' This distinguishes between: - Input arg type coercion (streams param as string) - continues to work as before - Manifest structure validation - now validates and errors with clear message Related CI run: https://github.com/airbytehq/connector-builder-mcp/actions/runs/18416705139/job/52481958952?pr=129 Co-Authored-By: AJ Steers <[email protected]>
Original prompt from AJ Steers
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
📝 WalkthroughWalkthroughAdds runtime validation to ensure manifest Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Test as Test Runner
participant Validator as validation_testing.run_connector_readiness_test_report
participant Manifest as manifest.streams
Test->>Validator: call with manifest
Validator->>Manifest: inspect streams field
alt streams is non-string and contains non-dict entries
Validator-->>Test: raise ValueError("Invalid manifest structure: streams ... must be list of stream definition objects")
else valid streams structure
Validator->>Validator: enumerate and validate each stream dict ('name' present, config)
Validator-->>Test: proceed to readiness tests
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
Comment |
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. Testing This Branch via MCPTo test the changes in this specific branch with an MCP client like Claude Desktop, use the following configuration: {
"mcpServers": {
"connector-builder-mcp-dev": {
"command": "uvx",
"args": ["--from", "git+https://github.com/airbytehq/connector-builder-mcp.git@devin/1728595175-fix-streams-validation", "connector-builder-mcp"]
}
}
} Testing This Branch via CLIYou can test this version of the MCP Server using the following CLI snippet: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/connector-builder-mcp.git@devin/1728595175-fix-streams-validation#egg=airbyte-connector-builder-mcp' --help PR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
connector_builder_mcp/validation_testing.py (1)
569-578
: LGTM! Validation correctly prevents AttributeError.The defensive validation properly catches malformed manifests where
streams
contains non-dict entries before attempting to call.get("name")
at line 580. The error message is clear and actionable, providing both the count and a sample of invalid entries.Edge cases are well-handled:
- Empty
available_streams
list is guarded by theif available_streams:
check- Missing
name
field in valid dicts is handled by the fallback at line 580Consider extracting this validation logic to a helper function in
_util.py
for better code organization and potential reuse:def validate_stream_entries(streams: list[Any]) -> None: """Validate that all stream entries are dictionaries. Raises: ValueError: If any stream entries are not dictionaries """ invalid_streams = [s for s in streams if not isinstance(s, dict)] if invalid_streams: raise ValueError( f"Invalid manifest structure: 'streams' must be a list of stream definition objects (dicts), " f"but found {len(invalid_streams)} invalid entry(ies). " f"Each stream should be a dict with at least a 'name' field and stream configuration. " f"Invalid entries: {invalid_streams[:3]}" )Then use it at line 569:
if available_streams: validate_stream_entries(available_streams)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
connector_builder_mcp/validation_testing.py
(1 hunks)tests/integration/test_validation_and_testing.py
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
tests/integration/test_validation_and_testing.py (1)
connector_builder_mcp/validation_testing.py (1)
run_connector_readiness_test_report
(500-738)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Pytest (All, Python 3.11, Ubuntu)
- GitHub Check: Pytest (All, Python 3.10, Ubuntu)
- GitHub Check: Run Evals (Single Connector)
- GitHub Check: Pytest (Fast)
🔇 Additional comments (1)
tests/integration/test_validation_and_testing.py (1)
177-201
: LGTM! Test coverage validates the fix.The test correctly verifies that malformed manifests with
streams
as a list of strings (instead of stream definition objects) raise aValueError
with the expected error message pattern. The test case directly addresses the root cause described in the PR.Test structure is appropriate:
- Minimal but valid manifest structure except for the malformed
streams
field- Uses
pytest.raises
with regex pattern matching to verify the error message- Calls
run_connector_readiness_test_report
without thestreams
parameter, ensuring the validation code path is exercised
fix: Add validation for manifest streams structure to prevent AttributeError
Summary
This PR fixes a bug where
run_connector_readiness_test_report
would crash withAttributeError: 'str' object has no attribute 'get'
when processing manifests with malformedstreams
fields.Root cause: The code assumed all entries in
manifest_dict["streams"]
are dictionaries with aname
field, but AI-generated manifests during eval runs sometimes contained a list of strings instead of stream definition objects.The fix: Added defensive validation that checks all stream entries are dicts before attempting to call
.get("name")
on them. If invalid entries are found, raises a clearValueError
with an actionable error message explaining what's wrong.Key distinction preserved:
streams
parameter can still be passed as a comma-separated string and gets coerced to a liststreams
field is now validated to ensure it contains properly formatted stream definition objectsReview & Testing Checklist for Human
validate_manifest
function)?Recommended Test Plan
pytest tests/integration/test_validation_and_testing.py::test_malformed_manifest_streams_validation -v
Notes
Summary by CodeRabbit
Bug Fixes
Tests
Important
Auto-merge enabled.
This PR is set to merge automatically when all requirements are met.