Skip to content

Feat: Add Hidden-Check Streams #585

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

agarctfi
Copy link
Contributor

@agarctfi agarctfi commented Jun 6, 2025

Context:
Some streams (in this case, HubSpot) have Dynamic Schema Loading, which makes them very resource-intensive to run CHECK. (See ref. OC Issue) We've temporarily increased the memory for CHECK, but this could incur a high cost for us if it remains in place permanently.

Solution: Create a less resource-intensive stream for the connector that can be used for CHECK only.

Issue we are trying to solve:
Currently, if the stream isn't part of the catalog, streams component of the manifest, it cannot be used for check.

We need to determine a way to create 'check-only' streams without exposing them to the user as streams they can sync.

Proposed solution:
Currently, CheckStream allows for an Array of Strings. Expand this to allow an array of Strings or an inline DeclarativeStream object.

Example current implementation (Source-Intercom used for this):

check:
  type: CheckStream
  stream_names:
    - tags

Example with the proposed solution:

check:
  type: CheckStream
  stream_names:
    - name: check_tags
      type: DeclarativeStream
      description: >-
        https://developers.intercom.com/docs/references/2.11/rest-api/api.intercom.io/tags/listtags
      primary_key:
        - name
      retriever:
        type: SimpleRetriever
        requester:
          $ref: "#/definitions/base_requester"
          path: tags
          http_method: GET
          request_headers:
            Accept: application/json
            Intercom-Version: "2.11"
          error_handler:
            type: CustomErrorHandler
            class_name: source_declarative_manifest.components.ErrorHandlerWithRateLimiter
            response_filters:
              - type: HttpResponseFilter
                http_codes:
                  - 401
                action: FAIL
                failure_type: config_error
                error_message: >-
                  Failed to perform request. Error: Permission Scope Error.
                  Please validate you have "Read tags" permission here: https://app.intercom.com/a/apps/_/developer-hub
        record_selector:
          type: RecordSelector
          extractor:
            type: DpathExtractor
            field_path:
              - data
      schema_loader:
        type: InlineSchemaLoader
        schema:
          $ref: "#/schemas/tags"

This will keep the defined stream in CheckStream hidden from the Streams component in the manifest, thus preventing users from syncing it.

Summary by CodeRabbit

  • New Features

    • Enhanced connection checks to support both named and inline stream definitions, allowing greater flexibility when specifying streams to check.
    • Users can now define check-only streams directly within configuration files using inline declarative stream objects.
  • Documentation

    • Updated schema documentation and examples to reflect support for inline declarative stream definitions in connection checks.

@Copilot Copilot AI review requested due to automatic review settings June 6, 2025 16:30
@github-actions github-actions bot added the enhancement New feature or request label Jun 6, 2025
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

Adds support for defining “check-only” streams inline in the CheckStream manifest, so they don’t appear in user-facing syncs.

  • Updates the Pydantic schema to accept either a stream name or a full DeclarativeStream in stream_names.
  • Implements a factory method in DeclarativeSource to build inline stream objects from dicts.
  • Refactors CheckStream.check_connection to instantiate and validate inline streams alongside catalog streams.

Reviewed Changes

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

File Description
airbyte_cdk/sources/declarative/models/declarative_component_schema.py Changed stream_names to List[Union[str, DeclarativeStream]] and updated examples
airbyte_cdk/sources/declarative/declarative_source.py Added _instantiate_stream_from_dict to create streams from inline definitions
airbyte_cdk/sources/declarative/models/declarative_component_schema.yaml Modified YAML schema to allow anyOf: string or DeclarativeStream for items
airbyte_cdk/sources/declarative/checks/check_stream.py Expanded check_connection to handle and validate inline stream definitions

@@ -1696,10 +1698,30 @@ class AuthFlow(BaseModel):

class CheckStream(BaseModel):
type: Literal["CheckStream"]
stream_names: Optional[List[str]] = Field(
stream_names: List[Union[str, "DeclarativeStream"]] = Field(
Copy link
Preview

Copilot AI Jun 6, 2025

Choose a reason for hiding this comment

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

The field has a default of None but is typed as a non-optional List, which can cause validation errors. Change the annotation to Optional[List[Union[str, DeclarativeStream]]] or remove the None default.

Suggested change
stream_names: List[Union[str, "DeclarativeStream"]] = Field(
stream_names: Optional[List[Union[str, "DeclarativeStream"]]] = Field(

Copilot uses AI. Check for mistakes.

return True, None
return True, None
except Exception as error:
return self._log_error(logger, "discovering streams", error)
Copy link
Preview

Copilot AI Jun 6, 2025

Choose a reason for hiding this comment

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

This catch-all block still logs its action as "discovering streams" even though it now wraps the entire check logic. Consider using a more accurate action string or narrowing the try/except scope.

Suggested change
return self._log_error(logger, "discovering streams", error)
return self._log_error(logger, "checking connection", error)

Copilot uses AI. Check for mistakes.

stream_name_to_stream = {s.name: s for s in streams}

# Add inline check-only streams to the map
for stream_def in self.stream_names:
Copy link
Preview

Copilot AI Jun 6, 2025

Choose a reason for hiding this comment

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

[nitpick] The code iterates over self.stream_names twice (once to instantiate inline streams, once to check availability). Consider consolidating these loops to reduce duplication and improve readability.

Suggested change
for stream_def in self.stream_names:
for stream_def in self.stream_names:
stream_obj = None

Copilot uses AI. Check for mistakes.

Copy link

github-actions bot commented Jun 6, 2025

PyTest Results (Fast)

564 tests   - 3 093   554 ✅  - 3 093   3m 5s ⏱️ - 2m 42s
  1 suites ±    0     9 💤  -     1 
  1 files   ±    0     1 ❌ +    1 

For more details on these failures, see this check.

Results for commit 138fc60. ± Comparison against base commit acc1003.

This pull request removes 3093 tests.
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_empty_stream
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_http_stream_via_availability_strategy[test_stream_available-200-True-expected_messages2]
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_http_stream_via_availability_strategy[test_stream_unavailable_handled_error-403-False-expected_messages1]
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_http_stream_via_availability_strategy[test_stream_unavailable_unhandled_error-404-False-expected_messages0]
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_stream1[test_check_http_dynamic_stream_and_config_dynamic_stream]
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_stream1[test_check_only_static_streams]
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_stream1[test_check_static_streams_and_config_dynamic_stream]
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_stream1[test_check_static_streams_and_http_dynamic_stream]
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_stream1[test_check_static_streams_and_http_dynamic_stream_and_config_dynamic_stream]
unit_tests.sources.declarative.checks.test_check_stream ‑ test_check_stream1[test_dynamic_stream_unauthorized_error]
…

Copy link
Contributor

coderabbitai bot commented Jun 6, 2025

📝 Walkthrough

Walkthrough

The updates expand the CheckStream functionality to support inline declarative stream definitions in addition to named streams. This involves updating type annotations, schema definitions, and instantiation logic to handle both string references and dictionary/object representations of streams during connection checks.

Changes

File(s) Change Summary
airbyte_cdk/sources/declarative/checks/check_stream.py Enhanced CheckStream to accept and process inline stream definitions; updated type annotations.
airbyte_cdk/sources/declarative/models/declarative_component_schema.py Changed stream_names in CheckStream to accept both strings and DeclarativeStream objects; updated examples and added forward references.
airbyte_cdk/sources/declarative/declarative_component_schema.yaml Updated schema to allow stream_names items to be strings or inline DeclarativeStream objects; revised description and examples.
airbyte_cdk/sources/declarative/declarative_source.py Added _instantiate_stream_from_dict method to support instantiating streams from dicts; added necessary imports.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CheckStream
    participant DeclarativeSource
    participant ModelToComponentFactory

    User->>CheckStream: check_connection(source, logger, config)
    CheckStream->>DeclarativeSource: get all streams (discovered + inline)
    alt Inline stream (dict)
        CheckStream->>DeclarativeSource: _instantiate_stream_from_dict(stream_def, config)
        DeclarativeSource->>ModelToComponentFactory: create_component(DeclarativeStreamModel, ...)
        ModelToComponentFactory-->>DeclarativeSource: DeclarativeStream instance
        DeclarativeSource-->>CheckStream: DeclarativeStream instance
    end
    CheckStream->>CheckStream: Validate stream availability
    CheckStream-->>User: Return check result (success/failure)
Loading

Suggested labels

enhancement

Suggested reviewers

  • lazebnyi

Would you like to add a test or example demonstrating the new inline stream definition capability in action, wdyt?

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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: 3

🧹 Nitpick comments (2)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1)

334-346: Consider adding a mixed string/object example?
Would it help to show a sample list combining both string references and inline objects in one stream_names array to illustrate realistic usage? wdyt?

 examples:
   - ["users"]
   - ["users", "contacts"]
   - name: "check_only_stream"
     type: DeclarativeStream
     retriever:
       type: SimpleRetriever
       requester:
         type: HttpRequester
         url_base: "https://api.example.com"
       record_selector:
         type: RecordSelector
         extractor:
           type: DpathExtractor
           field_path: []
+  - ["users",
+     { name: "check_only_stream",
+       type: DeclarativeStream,
+       retriever:
+         type: SimpleRetriever,
+         requester:
+           type: HttpRequester,
+           url_base: "https://api.example.com",
+         record_selector:
+           type: RecordSelector,
+           extractor:
+             type: DpathExtractor,
+             field_path: []
+     }
+    ]
airbyte_cdk/sources/declarative/checks/check_stream.py (1)

72-72: Consider alternatives to hasattr for feature detection

Using hasattr to check for method existence is fragile and makes the code harder to maintain. Have you considered:

  1. Making _instantiate_stream_from_dict a public method in the base class
  2. Using a protocol/interface to declare this capability
  3. Adding it as an abstract method with a default implementation

This would make the contract more explicit and type-safe. wdyt?

Also applies to: 81-81

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acc1003 and 138fc60.

📒 Files selected for processing (4)
  • airbyte_cdk/sources/declarative/checks/check_stream.py (3 hunks)
  • airbyte_cdk/sources/declarative/declarative_component_schema.yaml (1 hunks)
  • airbyte_cdk/sources/declarative/declarative_source.py (2 hunks)
  • airbyte_cdk/sources/declarative/models/declarative_component_schema.py (3 hunks)
🧰 Additional context used
🪛 GitHub Actions: Linters
airbyte_cdk/sources/declarative/declarative_source.py

[error] 53-53: mypy: Function is missing a return type annotation. (no-untyped-def)


[error] 53-53: mypy: Missing type parameters for generic type "dict". (type-arg)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Check: 'source-hardcoded-records' (skip=false)
  • GitHub Check: Check: 'source-pokeapi' (skip=false)
  • GitHub Check: Check: 'source-amplitude' (skip=false)
  • GitHub Check: Check: 'source-shopify' (skip=false)
  • GitHub Check: Pytest (All, Python 3.11, Ubuntu)
  • GitHub Check: Pytest (All, Python 3.10, Ubuntu)
  • GitHub Check: Pytest (Fast)
  • GitHub Check: SDM Docker Image Build
  • GitHub Check: Analyze (python)
🔇 Additional comments (5)
airbyte_cdk/sources/declarative/declarative_component_schema.yaml (2)

324-327: CheckStream stream_names description is clear
The updated description accurately conveys that items can be string references or inline DeclarativeStream objects.


328-331: items.anyOf correctly allows strings or inline streams
The schema now properly accepts either a string or a DeclarativeStream object for each entry.

airbyte_cdk/sources/declarative/models/declarative_component_schema.py (3)

1-2: LGTM! Standard copyright header addition.

The copyright header follows the expected format and is appropriately placed at the top of the file.


1701-1726: Verify the breaking change from optional to required field, wdyt?

The type change from Optional[List[str]] to List[Union[str, "DeclarativeStream"]] removes the optional nature of the field, which could be a breaking change for existing configurations. Is this intentional?

The expanded functionality looks great for supporting inline stream definitions, and the examples are comprehensive. The forward reference to "DeclarativeStream" is correctly handled.

Could you confirm that removing the optional nature aligns with the intended API design? If all CheckStream configurations should now specify stream_names, this makes sense. Otherwise, we might want to preserve the Optional wrapper.


2970-2970: LGTM! Necessary forward reference update.

The CheckStream.update_forward_refs() call is correctly added to resolve the forward reference to "DeclarativeStream" introduced in the CheckStream class. This is the proper way to handle circular references in Pydantic models.

Comment on lines +53 to +62
def _instantiate_stream_from_dict(self, stream_def: dict, config: Mapping[str, Any]):
"""
Instantiates a stream from a stream definition dict (used for check-only streams).
"""
factory = ModelToComponentFactory()
return factory.create_component(
model_type=DeclarativeStreamModel,
component_definition=stream_def,
config=config,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix type annotations for mypy compliance

The method is missing type annotations that are causing mypy failures. Also, since this is a private method that's used by CheckStream via hasattr, have you considered making it part of the public API to avoid the fragile feature detection pattern? wdyt?

-def _instantiate_stream_from_dict(self, stream_def: dict, config: Mapping[str, Any]):
+def _instantiate_stream_from_dict(self, stream_def: Dict[str, Any], config: Mapping[str, Any]) -> Any:

Also add the import at the top:

-from typing import Any, List, Mapping, Tuple
+from typing import Any, Dict, List, Mapping, Tuple
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def _instantiate_stream_from_dict(self, stream_def: dict, config: Mapping[str, Any]):
"""
Instantiates a stream from a stream definition dict (used for check-only streams).
"""
factory = ModelToComponentFactory()
return factory.create_component(
model_type=DeclarativeStreamModel,
component_definition=stream_def,
config=config,
)
# at the top of the file
from typing import Any, Dict, List, Mapping, Tuple
def _instantiate_stream_from_dict(
self,
stream_def: Dict[str, Any],
config: Mapping[str, Any],
) -> Any:
"""
Instantiates a stream from a stream definition dict (used for check-only streams).
"""
factory = ModelToComponentFactory()
return factory.create_component(
model_type=DeclarativeStreamModel,
component_definition=stream_def,
config=config,
)
🧰 Tools
🪛 GitHub Actions: Linters

[error] 53-53: mypy: Function is missing a return type annotation. (no-untyped-def)


[error] 53-53: mypy: Missing type parameters for generic type "dict". (type-arg)

🤖 Prompt for AI Agents
In airbyte_cdk/sources/declarative/declarative_source.py around lines 53 to 62,
add precise type annotations to the _instantiate_stream_from_dict method
signature to satisfy mypy, specifying the return type and parameter types
clearly. Additionally, consider renaming this method to remove the leading
underscore to make it part of the public API, which will avoid fragile feature
detection via hasattr. Finally, add the necessary import statements at the top
of the file to support the type annotations used.

"""

stream_names: List[str]
stream_names: List[Union[str, DeclarativeStream]]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Type annotation doesn't match docstring

The docstring mentions that stream_names can contain dicts (inline DeclarativeStream definitions from YAML), but the type annotation only includes str and DeclarativeStream. Should we update it to include dict as well? wdyt?

-stream_names: List[Union[str, DeclarativeStream]]
+stream_names: List[Union[str, Dict[str, Any], DeclarativeStream]]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
stream_names: List[Union[str, DeclarativeStream]]
- stream_names: List[Union[str, DeclarativeStream]]
+ stream_names: List[Union[str, Dict[str, Any], DeclarativeStream]]
🤖 Prompt for AI Agents
In airbyte_cdk/sources/declarative/checks/check_stream.py at line 39, the type
annotation for stream_names currently includes only str and DeclarativeStream,
but the docstring states it can also contain dicts representing inline
DeclarativeStream definitions from YAML. Update the type annotation to include
dict as well, changing it to List[Union[str, DeclarativeStream, dict]] to
accurately reflect the possible types.

Comment on lines +71 to +87
if isinstance(stream_def, dict):
if hasattr(source, "_instantiate_stream_from_dict"):
stream_obj = source._instantiate_stream_from_dict(stream_def, config)
stream_name_to_stream[stream_obj.name] = stream_obj
else:
raise NotImplementedError(
f"Source {type(source)} does not support inline stream definitions for check-only streams."
)
elif isinstance(stream_def, DeclarativeStream):
# Convert the Pydantic model to dict before passing to the factory
if hasattr(source, "_instantiate_stream_from_dict"):
stream_obj = source._instantiate_stream_from_dict(stream_def.dict(), config)
stream_name_to_stream[stream_obj.name] = stream_obj
else:
raise NotImplementedError(
f"Source {type(source)} does not support inline stream definitions for check-only streams."
)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor to eliminate code duplication

There's significant duplication between handling dict and DeclarativeStream types. What about extracting this into a helper method to make the code more DRY? wdyt?

-if isinstance(stream_def, dict):
-    if hasattr(source, "_instantiate_stream_from_dict"):
-        stream_obj = source._instantiate_stream_from_dict(stream_def, config)
-        stream_name_to_stream[stream_obj.name] = stream_obj
-    else:
-        raise NotImplementedError(
-            f"Source {type(source)} does not support inline stream definitions for check-only streams."
-        )
-elif isinstance(stream_def, DeclarativeStream):
-    # Convert the Pydantic model to dict before passing to the factory
-    if hasattr(source, "_instantiate_stream_from_dict"):
-        stream_obj = source._instantiate_stream_from_dict(stream_def.dict(), config)
-        stream_name_to_stream[stream_obj.name] = stream_obj
-    else:
-        raise NotImplementedError(
-            f"Source {type(source)} does not support inline stream definitions for check-only streams."
-        )
+if isinstance(stream_def, (dict, DeclarativeStream)):
+    if not hasattr(source, "_instantiate_stream_from_dict"):
+        raise NotImplementedError(
+            f"Source {type(source)} does not support inline stream definitions for check-only streams."
+        )
+    stream_dict = stream_def if isinstance(stream_def, dict) else stream_def.dict()
+    stream_obj = source._instantiate_stream_from_dict(stream_dict, config)
+    stream_name_to_stream[stream_obj.name] = stream_obj
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if isinstance(stream_def, dict):
if hasattr(source, "_instantiate_stream_from_dict"):
stream_obj = source._instantiate_stream_from_dict(stream_def, config)
stream_name_to_stream[stream_obj.name] = stream_obj
else:
raise NotImplementedError(
f"Source {type(source)} does not support inline stream definitions for check-only streams."
)
elif isinstance(stream_def, DeclarativeStream):
# Convert the Pydantic model to dict before passing to the factory
if hasattr(source, "_instantiate_stream_from_dict"):
stream_obj = source._instantiate_stream_from_dict(stream_def.dict(), config)
stream_name_to_stream[stream_obj.name] = stream_obj
else:
raise NotImplementedError(
f"Source {type(source)} does not support inline stream definitions for check-only streams."
)
if isinstance(stream_def, (dict, DeclarativeStream)):
if not hasattr(source, "_instantiate_stream_from_dict"):
raise NotImplementedError(
f"Source {type(source)} does not support inline stream definitions for check-only streams."
)
stream_dict = stream_def if isinstance(stream_def, dict) else stream_def.dict()
stream_obj = source._instantiate_stream_from_dict(stream_dict, config)
stream_name_to_stream[stream_obj.name] = stream_obj
🤖 Prompt for AI Agents
In airbyte_cdk/sources/declarative/checks/check_stream.py around lines 71 to 87,
the code handling stream_def when it is a dict or a DeclarativeStream is
duplicated. Refactor by extracting the common logic of checking for
_instantiate_stream_from_dict and creating the stream object into a helper
method that accepts the stream definition (converted to dict if needed) and
config. Replace the duplicated blocks with calls to this helper to make the code
DRY and easier to maintain.

Copy link

github-actions bot commented Jun 6, 2025

PyTest Results (Full)

3 660 tests  ±0   3 647 ✅  - 3   17m 24s ⏱️ +4s
    1 suites ±0      10 💤 ±0 
    1 files   ±0       3 ❌ +3 

For more details on these failures, see this check.

Results for commit 138fc60. ± Comparison against base commit acc1003.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant