airbyte icon indicating copy to clipboard operation
airbyte copied to clipboard

🐛 [cdk] Return correct type during 'check' if config does not match schema

Open yfyf opened this issue 1 year ago • 3 comments
trafficstars

What

This fixes a bug where, upon config validation against the JSON schema failure, the run_cmd function would yield the connection status message in the form of a serialized JSON (i.e. str). This violated the output signature of Iterable[AirbyteMessage] and would produce unclear errors when run from the CLI.

Curiously, mypy did not catch this simple type error, though pyright did.

How

Yield the correct type upon exception.

Review guide

It's a one-line change, except for the test.

Added a small unit test that covers this scenario.

User Impact

When running check --config bad-config.json, it would throw up with:

{"type": "LOG", "log": {"level": "FATAL", "message": "'str' object has no attribute 'json'\nTraceback <..>}}
{"type": "TRACE", "trace": {"type": "ERROR", <..>}}

Now it produces a clear message:

 {"type": "CONNECTION_STATUS", "connectionStatus": {"status": "FAILED", "message": "Config validation error: 'foo' is a required property"}}

Can this PR be safely reverted and rolled back?

  • [X] YES 💚
  • [ ] NO ❌

yfyf avatar Apr 18 '24 08:04 yfyf

Your free trial has expired. To continue using Ellipsis, sign up at https://app.ellipsis.dev for $20/developer/month. If you have any questions, reach us at [email protected]

ellipsis-dev[bot] avatar Apr 18 '24 08:04 ellipsis-dev[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 24, 2024 1:33pm

vercel[bot] avatar Apr 18 '24 08:04 vercel[bot]

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Apr 18 '24 08:04 CLAassistant

Uh oh, we missed it. @yfyf thank you for the fix! Let me spin up CI on this and merge if everything looks fine.

natikgadzhi avatar May 22 '24 15:05 natikgadzhi

@alafanechere will add CDK to allowed paths to trigger community CI and then merge this :D

natikgadzhi avatar May 22 '24 15:05 natikgadzhi

@alafanechere I'm sorry, but I can't dedicate more time to this at the moment. It is also a code maintenance change that isn't related to the bug fix.

On Fri, May 24, 2024, 16:42 Augustin @.***> wrote:

@.**** requested changes on this pull request.

Hey @yfyf https://github.com/yfyf , we run mypy on modified files in CI. Would you mind fixing the following error on the destination.py module?

airbyte-cdk/python/airbyte_cdk/destinations/destination.py:115: error: Function is missing a return type annotation [no-untyped-def]

— Reply to this email directly, view it on GitHub https://github.com/airbytehq/airbyte/pull/37398#pullrequestreview-2076974363, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFZNDVSO33HINCXQN24HTTZD47VZAVCNFSM6AAAAABGMY2W4WVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDANZWHE3TIMZWGM . You are receiving this because you were mentioned.Message ID: @.***>

yfyf avatar May 24 '24 14:05 yfyf

Since this is not a net new mypy error and it's unrelated to the actual change, I'll merge this as is. Thank you for the contribution, @yfyf!

natikgadzhi avatar May 25 '24 00:05 natikgadzhi