Skip to content
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

Connector builder server: No records returned if no schema loader is defined for a stream #21381

Closed
flash1293 opened this issue Jan 13, 2023 · 0 comments · Fixed by #21516 or #21658
Closed
Assignees

Comments

@flash1293
Copy link
Contributor

The connector builder server is not returning records if no schema loader is defined as part of the manifest even though the schema loader is marked as optional in the typings.

To reproduce:

Issue a read request with a payload like this (defines a valid stream but without a schema loader defined

{
    "manifest": {
        "version": "0.1.0",
        "type": "DeclarativeSource",
        "check": {
            "type": "CheckStream",
            "stream_names": []
        },
        "streams": [
            {
                "type": "DeclarativeStream",
                "name": "test",
                "primary_key": [],
                "retriever": {
                    "type": "SimpleRetriever",
                    "name": "test",
                    "primary_key": [],
                    "requester": {
                        "type": "HttpRequester",
                        "name": "test",
                        "url_base": "http://dummy_api:6767/",
                        "path": "items/",
                        "request_options_provider": {
                            "request_parameters": {},
                            "request_headers": {},
                            "request_body_json": {}
                        },
                        "authenticator": {
                            "type": "BearerAuthenticator",
                            "api_token": "{{ config['api_key'] }}"
                        }
                    },
                    "record_selector": {
                        "type": "RecordSelector",
                        "extractor": {
                            "type": "DpathExtractor",
                            "field_pointer": [
                                "items"
                            ]
                        }
                    },
                    "paginator": {
                        "type": "NoPagination"
                    }
                }
            }
        ],
        "spec": {
            "connection_specification": {
                "$schema": "http://json-schema.org/draft-07/schema#",
                "type": "object",
                "required": [
                    "api_key"
                ],
                "properties": {
                    "api_key": {
                        "type": "string",
                        "title": "API Key",
                        "airbyte_secret": true
                    }
                },
                "additionalProperties": true
            },
            "documentation_url": "",
            "type": "Spec"
        }
    },
    "stream": "test",
    "config": {
        "api_key": "theauthkey"
    }
}

Builder server logs the following:

airbyte-connector-builder-server  | {"type": "DEBUG", "message": "Making outbound API request", "data": {"headers": "{'User-Agent': 'python-requests/2.28.2', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Authorization': 'Bearer theauthkey'}", "url": "http://dummy_api:6767/items", "request_body": "None"}}

airbyte-connector-builder-server  | {"type": "DEBUG", "message": "Receiving response", "data": {"body": "{\"items\":[{\"name\":\"abc\"},{\"name\":\"def\"}]}", "status": "200", "headers": "{'Content-Type': 'application/json', 'Date': 'Fri, 13 Jan 2023 11:20:43 GMT', 'Connection': 'keep-alive', 'Keep-Alive': 'timeout=5', 'Transfer-Encoding': 'chunked'}"}}

airbyte-connector-builder-server  | {"type": "LOG", "log": {"level": "ERROR", "message": "Encountered an exception while reading stream test\nTraceback (most recent call last):\n  File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/declarative/schema/default_schema_loader.py\", line 40, in get_json_schema\n    return self.default_loader.get_json_schema()\n  File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/declarative/schema/json_file_schema_loader.py\", line 62, in get_json_schema\n    raise IOError(f\"Cannot find file {json_schema_path}\")\nOSError: Cannot find file ./.json\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py\", line 111, in read\n    yield from self._read_stream(\n  File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py\", line 180, in _read_stream\n    for record in record_iterator:\n  File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py\", line 291, in _read_full_refresh\n    message = self._get_message(record_data_or_message, stream_instance)\n  File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/abstract_source.py\", line 325, in _get_message\n    return stream_data_to_airbyte_message(stream.name, record_data_or_message, stream.transformer, stream.get_json_schema())\n  File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/declarative/declarative_stream.py\", line 132, in get_json_schema\n    return self._schema_loader.get_json_schema()\n  File \"/usr/local/lib/python3.9/site-packages/airbyte_cdk/sources/declarative/schema/default_schema_loader.py\", line 44, in get_json_schema\n    stream_name = self._options.get(\"name\", \"\")\nAttributeError: 'NoneType' object has no attribute 'get'"}}

Then returns an empty records array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment