Skip to content

Conversation

aaronsteers
Copy link
Contributor

@aaronsteers aaronsteers commented Oct 10, 2025

fix(validation): Auto-enable raw responses when zero records extracted

Summary

Fixes a bug in execute_stream_test_read where raw_api_responses were not being auto-enabled when zero records were extracted due to incorrect dpath configuration, even though the code comment indicated this should happen.

The Problem:

  • Line 437 comment states: "Toggle to include_raw_responses=True if we had an error or if we are returning no records"
  • Line 438 implementation only checked not success, missing the zero records case
  • When API calls succeeded but dpath extraction yielded 0 records, success remained True and raw responses weren't auto-enabled
  • This prevented developers from getting debugging information for dpath configuration issues

The Fix:

  • Added or len(records_data) == 0 to the auto-enable condition
  • Now raw responses are auto-enabled when: API errors occur OR zero records are extracted
  • Matches the documented behavior in the code comment above

Review & Testing Checklist for Human

  • Test zero-records auto-enable: Create a manifest with wrong dpath (e.g., field_path: ["results"] for JSONPlaceholder API), call execute_stream_test_read with include_raw_responses_data=false, and verify raw_api_responses is populated (not null)
  • Test normal scenarios: Verify raw responses behave correctly for successful extractions and explicit enabling/disabling
  • Verify no unintended auto-enabling: Ensure raw responses aren't auto-enabled in scenarios where they shouldn't be (successful API calls with records extracted and raw responses explicitly disabled)

Notes

The fix is minimal and targeted, addressing the exact discrepancy between documented and actual behavior without changing the broader logic flow.

Summary by CodeRabbit

  • Bug Fixes

    • Validation tests now include raw API responses when requests fail or when zero records are returned; a warning is logged if zero records are read despite a reported success to prompt review of raw responses.
  • Documentation

    • Clarified raw-response option: None auto-enables raw data on errors or zero records, True always includes, False excludes unless zero records occur.

Fixes #126

The auto-enable logic for raw_api_responses was only checking 'not success'
but success remained True when API calls succeeded even if dpath extraction
resulted in zero records. This prevented developers from getting debugging
information for dpath configuration issues.

Updated line 438 to also check len(records_data) == 0 to match the documented
behavior in the comment above it.

Testing:
- Verified with wrong dpath manifest that raw responses now auto-enable
- All tests pass (97 passed, 2 skipped, 1 xfailed)
- Lint and format checks pass

Co-Authored-By: AJ Steers <[email protected]>
Copy link
Contributor

Original prompt from AJ Steers
@Devin - Can you tackle this? <https://github.com/airbytehq/connector-builder-mcp/issues/121>
Thread URL: https://airbytehq-team.slack.com/archives/D089P0UPVT4/p1760119796023459?thread_ts=1760119796.023459

Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions github-actions bot added the bug Something isn't working label Oct 10, 2025
Copy link

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

Testing This Branch via MCP

To 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/1760122860-fix-auto-enable-raw-responses", "connector-builder-mcp"]
    }
  }
}

Testing This Branch via CLI

You 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/1760122860-fix-auto-enable-raw-responses#egg=airbyte-connector-builder-mcp' --help

PR Slash Commands

Airbyte Maintainers can execute the following slash commands on your PR:

  • /autofix - Fixes most formatting and linting issues
  • /poe <command> - Runs any poe command in the uv virtual environment
  • /poe build-connector prompt="Star Wars API" - Run the connector builder using the Star Wars API.

📝 Edit this welcome message.

Copy link

coderabbitai bot commented Oct 10, 2025

📝 Walkthrough

Walkthrough

Expanded execute_stream_test_read logic to ensure raw API responses are included when the explicit flag is true, when the operation failed, or when zero records were extracted; also logs a warning and forces inclusion of raw responses when zero records are returned despite overall success. No public interfaces changed.

Changes

Cohort / File(s) Summary
Validation testing logic update
connector_builder_mcp/validation_testing.py
Broadened auto-enable semantics for include_raw_responses_data: it is now enabled when the explicit flag is true, or when success is false, or when len(records_data) == 0. Added a warning log when zero records are read despite success == True.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant Validator as execute_stream_test_read
  participant API

  Caller->>Validator: invoke(stream_name, config, include_raw_responses_data?)
  Validator->>API: request data
  API-->>Validator: response (slices, payload)
  Note over Validator: extract records_data\ncompute success (based on response)
  alt include_raw_responses_data == True\nor success == False\nor len(records_data) == 0
    Validator->>Validator: include raw_api_responses (log warning if zero records but success)
  else
    Validator->>Validator: raw_api_responses = null
  end
  Validator-->>Caller: return result (records_read, success, raw_api_responses)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely summarizes the primary fix of auto-enabling raw responses when zero records are extracted in validation tests, matching the main change in the diff without unnecessary detail or noise.
Linked Issues Check ✅ Passed The patch updates the condition to include len(records_data) == 0 alongside error detection, logs a warning for zero-record scenarios, and ensures raw_api_responses are auto-enabled as specified in issue #126, with tests verifying normal and edge cases.
Out of Scope Changes Check ✅ Passed All changes are confined to the include_raw_responses_data logic in validation_testing.py and directly address the bug in issue #126 without introducing unrelated modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch devin/1760122860-fix-auto-enable-raw-responses

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b0cbaf and 3c60dab.

📒 Files selected for processing (1)
  • connector_builder_mcp/validation_testing.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • connector_builder_mcp/validation_testing.py
⏰ 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)
  • GitHub Check: Test Connector Build (JSONPlaceholder)
  • GitHub Check: Test Connector Build (PokemonTGG)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Run Evals (Single Connector)

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

github-actions bot commented Oct 10, 2025

PyTest Results (Fast)

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit 3c60dab. ± Comparison against base commit f0ceb07.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Oct 10, 2025

PyTest Results (Full)

0 tests   0 ✅  0s ⏱️
0 suites  0 💤
0 files    0 ❌

Results for commit 3c60dab.

♻️ This comment has been updated with latest results.

@aaronsteers aaronsteers requested a review from Copilot October 10, 2025 19:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the validation testing logic where raw API responses were not being auto-enabled when zero records were extracted, despite the code comment indicating this should happen. The fix ensures that developers get debugging information when dpath configuration issues cause zero records to be extracted from successful API calls.

  • Adds the missing zero records condition to the auto-enable logic for raw responses
  • Aligns the actual implementation with the documented behavior in the code comment
  • Provides critical debugging support for dpath configuration issues

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

devin-ai-integration bot and others added 2 commits October 10, 2025 19:19
…verridden for zero records

Update the parameter description for include_raw_responses_data to clearly
document that when set to False, raw responses will still be auto-enabled
if zero records are extracted. This ensures developers understand the
override behavior for debugging scenarios.

Related to #126

Co-Authored-By: AJ Steers <[email protected]>
Add explicit warning message to execution logs when a successful API call
returns zero records, alerting users to review raw responses to verify
the result is correct (e.g., not due to incorrect dpath configuration).

The warning message reads: 'Read attempt returned zero records. Please
review the included raw responses to ensure the zero-records result is
correct.'

Related to #126

Co-Authored-By: AJ Steers <[email protected]>
Copy link

@coderabbitai coderabbitai bot left a 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)

439-439: Fix correctly addresses the zero-records bug.

The extended condition now auto-enables raw responses when API calls succeed but dpath extraction yields zero records, which is exactly the debugging scenario described in issue #126. The logic properly distinguishes between API errors (not success) and successful-but-empty extractions (len(records_data) == 0).

Optional style refinement:

Consider using the more Pythonic empty-check idiom:

-    include_raw_responses_data = include_raw_responses_data or not success or len(records_data) == 0
+    include_raw_responses_data = include_raw_responses_data or not success or not records_data

Both are correct; not records_data is slightly more idiomatic for empty-sequence checks in Python.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e13ea8 and 8b0cbaf.

📒 Files selected for processing (1)
  • connector_builder_mcp/validation_testing.py (2 hunks)
⏰ 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)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: Test Connector Build (JSONPlaceholder)
  • GitHub Check: Test Connector Build (PokemonTGG)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Run Evals (Single Connector)
🔇 Additional comments (2)
connector_builder_mcp/validation_testing.py (2)

331-333: LGTM! Clear documentation of auto-enable behavior.

The docstring accurately describes the tri-state behavior and makes the debugging intent explicit. The clarification that False is overridden for zero-records scenarios is particularly helpful.


441-447: LGTM! Helpful debugging guidance.

The warning appropriately triggers only when zero records are extracted despite a successful read operation, guiding users to inspect the raw responses for dpath configuration issues. The log format is consistent with the existing codebase.

Refactor the auto-enable logic for raw responses to make it clearer:
- Explicitly set include_raw_responses_data=True inside the zero-records
  warning block
- Simplify the final OR expression to only check 'not success'

This makes the code more readable and maintainable by separating the
zero-records override from the error handling.

Addresses PR feedback from @aaronsteers

Related to #126

Co-Authored-By: AJ Steers <[email protected]>
@aaronsteers aaronsteers merged commit af2f6c7 into main Oct 10, 2025
18 checks passed
@aaronsteers aaronsteers deleted the devin/1760122860-fix-auto-enable-raw-responses branch October 10, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Auto-enable raw responses not working for zero-record scenarios Bug: Auto-enable for raw_api_responses not working when zero records extracted

1 participant