Harel Trabelsi
10/09/2025, 11:20 AMkapa.ai
10/09/2025, 11:20 AMcheck_connection method, iterate over the available streams, attempt to read at least one record, and only return success if a record is found. 2. Return a user-friendly error if no records are found or if authentication fails. Here is a code example, directly from the Airbyte documentation, that demonstrates this approach: python from airbyte_cdk.models import AirbyteMessage, SyncMode def check_connection(self, logger, config) -> Tuple[bool, any]: first_stream = next(iter(self.streams(config))) stream_slice = next(iter(first_stream.stream_slices(sync_mode=SyncMode.full_refresh))) try: read_stream = first_stream.read_records(sync_mode=SyncMode.full_refresh, stream_slice=stream_slice) first_record = None while not first_record: first_record = next(read_stream) if isinstance(first_record, AirbyteMessage): if first_record.type == "RECORD": first_record = first_record.record return True, None else: first_record = None return True, None except Exception as e: return False, f"Unable to connect to the API with the provided credentials - {str(e)}" This implementation: - Tries to read a record from the first stream. - Returns success only if a record is found. - Returns a clear error message if it fails to connect or retrieve a record. Why this is recommended: This approach ensures that your connector not only has access to the API (i.e., receives HTTP 200 OK), but also that it can actually retrieve data, which is a stronger guarantee of correct configuration and permissions. For further improvements, you can also implement more advanced error handling to provide actionable feedback to users, as described in the Airbyte best practices documentation. For example, you can raise a configuration error with a user-friendly message if authentication fails or if no records are found in the stream. This helps users quickly identify and resolve configuration issues without digging through logs[Check and error handling](https://docs.airbyte.com/platform/next/connector-development/tutorials/custom-python-connector/check-and-error-handling). References: - [Check and error handling](https://docs.airbyte.com/platform/next/connector-development/tutorials/custom-python-connector/check-and-error-handling) - [Quality certification checklist](https://docs.airbyte.com/platform/next/connector-development/best-practices#quality-certification-checklist)Harel Trabelsi
10/09/2025, 11:21 AM