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

🚨🚨 [ISSUE #19733] Executing a source with an invalid JSON file should display a clear error #19931

Conversation

maxi297
Copy link
Contributor

@maxi297 maxi297 commented Nov 30, 2022

What

This change address #19733 which would cause the error message from reading config files to be unclear.

How

As #19733 states, We should rename BaseConnector.read_config() to read_json_file() to accurately reflect what it is doing. The existing usages of read_config() should be updated. and The Source.read_state() method should start using this newly renamed read_json_file() to read the state JSON file instead of duplicating all the same file reading logic.

🚨 User Impact 🚨

Previous error message: Expecting value: line 1 column 1 (char 0)
New error message: Could not read json file secrets/config.json: Expecting value: line 1 column 1 (char 0)

The solution proposed in #19733 is a breaking change since the public method read_config is changed to read_json_file.

Pre-merge Checklist

Community member or Airbyter

  • Unit & integration tests added and passing
  • Code reviews completed
  • PR name follows PR naming conventions

Tests

Unit

Put your unit tests output here.

Integration

Put your integration tests output here.

Acceptance

Put your acceptance tests output here.

Other Notes

Running mypy airbyte_cdk (as mentioned in the README.md) before creating changes to the repository gave me the following output Found 134 errors in 60 files (checked 140 source files). Is this expected?

@maxi297 maxi297 requested a review from a team as a code owner November 30, 2022 17:22
@CLAassistant
Copy link

CLAassistant commented Nov 30, 2022

CLA assistant check
All committers have signed the CLA.

@octavia-squidington-iv octavia-squidington-iv added the CDK Connector Development Kit label Nov 30, 2022
Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

Nice work! The main change looks good to me. Request for change: more connectors use this method, so we should make sure to update them as well:


airbyte-integrations/connectors/source-s3/source_s3/source.py:
  60      def read_config(self, config_path: str) -> Mapping[str, Any]:
  61:         config: Mapping[str, Any] = super().read_config(config_path)
  62          if config.get("format", {}).get("delimiter") == r"\t":

airbyte-integrations/connectors/source-s3/unit_tests/conftest.py:
  51      source = SourceS3()
  52:     config = source.read_config(config_file)
  53      return config

airbyte-integrations/connectors/source-s3/unit_tests/test_source.py:
  21      source = SourceS3()
  22:     config = source.read_config(config_file)
  23      assert config["format"]["delimiter"] == "\t"

airbyte-cdk/python/airbyte_cdk/connector.py Outdated Show resolved Hide resolved
Copy link
Contributor

@brianjlai brianjlai left a comment

Choose a reason for hiding this comment

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

changes and additional tests look good. great work!

Will approve pending the update to the s3 source which appears to be the only source that was using read_config(). I think we also discussed async, but the json file reading in BaseConnector.spec() to reuse what you built here will be in a follow up PR?

airbyte-cdk/python/CHANGELOG.md Show resolved Hide resolved
@maxi297 maxi297 force-pushed the issue-19733_cdk-clarify-config-error-message-for-config-files branch from 5189af9 to e9507a4 Compare December 1, 2022 15:02
Copy link
Contributor

@brianjlai brianjlai left a comment

Choose a reason for hiding this comment

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

looks good! just responses to the comments you left

airbyte-cdk/python/airbyte_cdk/connector.py Show resolved Hide resolved
airbyte-cdk/python/airbyte_cdk/connector.py Show resolved Hide resolved
@maxi297
Copy link
Contributor Author

maxi297 commented Dec 2, 2022

Since this merge request was from a forked repo, it had to be reopened in the current airbyte repo. Here is the new PR for this change: #20019

@maxi297 maxi297 closed this Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/connectors Connector related issues CDK Connector Development Kit connectors/source/s3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants