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

BugFix: Improve support for special characters in DbApiHook.get_uri #12775

Merged
merged 2 commits into from
Dec 7, 2020

Conversation

alokshenoy
Copy link
Contributor

Closes #12722 raised by @NadimYounes

  • Uses urllib.parse.quote_plus to urlencode the password since SQLAlchemy requires a valid URI to create an engine.

  • Adds test case that checks for encoding of password.

@@ -78,7 +79,7 @@ def get_uri(self) -> str:
conn = self.get_connection(getattr(self, self.conn_name_attr))
login = ''
if conn.login:
login = '{conn.login}:{conn.password}@'.format(conn=conn)
login = '{conn.login}:{quote_plus(conn.password)}@'.format(conn=conn)
Copy link
Member

Choose a reason for hiding this comment

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

Does this problem also apply to the login?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. It could. To be safe, we should apply the same to login too.

Copy link
Member

Choose a reason for hiding this comment

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

It does -- hosted Postgresql service on Azure has an @ in the username.

@alokshenoy alokshenoy force-pushed the fix-urlencoded-db-password branch from 4c06047 to 668f1b6 Compare December 3, 2020 08:53
@github-actions
Copy link

github-actions bot commented Dec 3, 2020

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@github-actions
Copy link

github-actions bot commented Dec 3, 2020

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@alokshenoy
Copy link
Contributor Author

Looking into the static check failure.

@github-actions
Copy link

github-actions bot commented Dec 3, 2020

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@alokshenoy alokshenoy force-pushed the fix-urlencoded-db-password branch from cee827c to 643143f Compare December 3, 2020 19:24
Closes [apache#12722](apache#12722) raised by @NadimYounes

- Uses urllib.parse.quote_plus to urlencode the username (login) and  password since SQLAlchemy requires a valid URI to create an engine.

- Adds test case that checks for encoding of the username (login) and password.

Co-authored-by: Ash Berlin-Taylor <[email protected]>
@alokshenoy alokshenoy force-pushed the fix-urlencoded-db-password branch from 643143f to 6127e8a Compare December 4, 2020 00:18
@alokshenoy
Copy link
Contributor Author

@NadimYounes , @ashb - This is ready to be reviewed.

@alokshenoy alokshenoy requested a review from ashb December 4, 2020 18:52
@mik-laj mik-laj added this to the Airflow 2.0.0 (rc1) milestone Dec 4, 2020
@potiuk
Copy link
Member

potiuk commented Dec 7, 2020

@mik-laj - does it look good for you as well ? I would like to merge it, but need a second pair of eyes :)

@github-actions
Copy link

github-actions bot commented Dec 7, 2020

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Dec 7, 2020
@mik-laj mik-laj merged commit 01707d7 into apache:master Dec 7, 2020
@mik-laj mik-laj changed the title BugFix: Adds support for special characters in DbApiHook BugFix: Improve support for special characters in DbApiHook.get_uri Dec 7, 2020
@alokshenoy alokshenoy deleted the fix-urlencoded-db-password branch December 7, 2020 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
full tests needed We need to run full set of tests for this PR to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No Support for special Characters in Passwords for get_uri() method in DbApiHook
4 participants