Skip to content

Correctly handle multiple '=' in LocalFileSystem secrets.#21694

Merged
uranusjr merged 1 commit into
apache:mainfrom
kadai0308:fix-parse-func-of-env-file-in-LocalFileSystem-secrets
Feb 24, 2022
Merged

Correctly handle multiple '=' in LocalFileSystem secrets.#21694
uranusjr merged 1 commit into
apache:mainfrom
kadai0308:fix-parse-func-of-env-file-in-LocalFileSystem-secrets

Conversation

@kadai0308

@kadai0308 kadai0308 commented Feb 20, 2022

Copy link
Copy Markdown
Contributor

Related issue: #21625

If there is another '=' in the conn string in the env file, it will been splited into 3 sub-string which is not expected( We expect it only been splited into 2 sub-string, key and value ).

For example,

MY_CONN_ID=my-conn-type://my-login:my-pa%2Fssword@my-host:5432/my-schema?param1=val1&param2=val2

it will been splited into:

['MY_CONN_ID', 'my-conn-type://my-login:my-pa%2Fssword@my-host:5432/my-schema?param1', 'val1&param2=val2']

and it will cause ValueError: too many values to unpack (expected 2) laster at line 87 .

key, value = var_parts

It can been fixed by correct the maxsplit to 1 of line split use partition instead in _parse_env_file function in LocalFileSystem secrets.

Python docs: https://docs.python.org/3.11/library/stdtypes.html?#str.split


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

@boring-cyborg

boring-cyborg Bot commented Feb 20, 2022

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: dev@airflow.apache.org
    Slack: https://s.apache.org/airflow-slack

@kadai0308 kadai0308 changed the title fix maxsplit of line split (by '=') in _parse_env_file function set maxsplit to be 1 of line split in _parse_env_file function Feb 20, 2022
@kadai0308 kadai0308 force-pushed the fix-parse-func-of-env-file-in-LocalFileSystem-secrets branch from 0564950 to 6a9f1e3 Compare February 20, 2022 15:21
@mik-laj

mik-laj commented Feb 20, 2022

Copy link
Copy Markdown
Member

Can you add tests to avoid regression?

@kadai0308

Copy link
Copy Markdown
Contributor Author

Can you add tests to avoid regression?

Sure

Comment thread airflow/secrets/local_filesystem.py Outdated
@github-actions

Copy link
Copy Markdown
Contributor

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 main 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 Feb 21, 2022
@kadai0308 kadai0308 force-pushed the fix-parse-func-of-env-file-in-LocalFileSystem-secrets branch from 1f1d7d1 to 1ac080a Compare February 21, 2022 09:13
@kadai0308 kadai0308 force-pushed the fix-parse-func-of-env-file-in-LocalFileSystem-secrets branch 3 times, most recently from 5fe5eed to 5aea091 Compare February 22, 2022 09:06
@kadai0308 kadai0308 changed the title set maxsplit to be 1 of line split in _parse_env_file function use partition instead of split in _parse_env_file function in LocalFileSystem secrets. Feb 22, 2022
@kadai0308 kadai0308 force-pushed the fix-parse-func-of-env-file-in-LocalFileSystem-secrets branch 6 times, most recently from dbd49c3 to 63b657c Compare February 23, 2022 15:01
@kadai0308 kadai0308 force-pushed the fix-parse-func-of-env-file-in-LocalFileSystem-secrets branch from 63b657c to 50f8a62 Compare February 24, 2022 02:26
@kadai0308 kadai0308 force-pushed the fix-parse-func-of-env-file-in-LocalFileSystem-secrets branch from 50f8a62 to 82010d0 Compare February 24, 2022 05:44
@uranusjr uranusjr changed the title use partition instead of split in _parse_env_file function in LocalFileSystem secrets. Correctly handle multiple '=' in LocalFileSystem secrets. Feb 24, 2022
@uranusjr uranusjr merged commit 919b75b into apache:main Feb 24, 2022
@boring-cyborg

boring-cyborg Bot commented Feb 24, 2022

Copy link
Copy Markdown

Awesome work, congrats on your first merged pull request!

rustikk pushed a commit to rustikk/airflow that referenced this pull request Feb 25, 2022
@jedcunningham jedcunningham added the type:bug-fix Changelog: Bug Fixes label Feb 28, 2022
@jedcunningham jedcunningham added this to the Airflow 2.2.5 milestone Feb 28, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 16, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 20, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 22, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 24, 2022
ephraimbuddy pushed a commit that referenced this pull request Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:secrets full tests needed We need to run full set of tests for this PR to merge type:bug-fix Changelog: Bug Fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants