MeltanoLabs / tap-snowflake

Other
4 stars 10 forks source link

Catalog discovery failing when using browser authentication #48

Open dlouseiro opened 1 month ago

dlouseiro commented 1 month ago

While using the tap-snowflake with use_browser_authentication=True, my catalog discovery fails with Run invocation could not be completed as block failed: Cannot start plugin tap-snowflake: Catalog discovery failed: invalid catalog: Expecting value: line 1 column 1 (char 0). A bit of a cryptic error.

After investigating a bit further with meltano invoke tap-snowflake --discover > catalog.json, I noticed that the Snowflake connector sends the browser authentication logs to stdout, so the first line in my catalog is:

Initiating login request with your identity provider. A browser window should have opened for you to complete the login. If you can't see it, check existing browser windows, or your OS settings. Press CTRL+C to abort and try again...
Going to open: https://accounts.google.com/o/...to authenticate

After looking a bit deeper into the snowflake-connector-python, it seems that they use print() for this message here, which causes the issue.

dlouseiro commented 1 month ago

It seems that the issue was already reported here.

dlouseiro commented 1 month ago

Also cross-posted this issue here.

dlouseiro commented 4 weeks ago

Hey @edgarrmondragon , I don't see much traction on the related issue on the Snowflake side as it seems they have their reasons to use a print instead of a logger in this case, polluting stdout.

Do you think we could implement some type of (maybe a bit dirty) workaround here in the tap-snowflake?

edgarrmondragon commented 4 weeks ago

If we know the point at which the call chain starts on our end, we could try using contextlib.redirect_stdout(sys.stderr).