Skip to content

Provide default for EXCLUDED_PROVIDERS lookup.#43385

Merged
potiuk merged 1 commit into
apache:mainfrom
perry2of5:dflt-to-empty-map-when-env-var-not-defined
Oct 25, 2024
Merged

Provide default for EXCLUDED_PROVIDERS lookup.#43385
potiuk merged 1 commit into
apache:mainfrom
perry2of5:dflt-to-empty-map-when-env-var-not-defined

Conversation

@perry2of5
Copy link
Copy Markdown
Contributor

The current code throws a KeyError when the environment variable EXCLUDED_PROVIDERS is not defined. This commit adds an empty map as a default to prevent this failure.

This was discovered while trying to replicate the issue with microsoft-kiota-http logged here:
microsoftgraph/msgraph-sdk-python-core#706

breeze testing tests --force-lowest-dependencies --test-type "Providers[microsoft.azure]"

Before:

Forcing dependencies to lowest versions for provider: [microsoft-azure]

Traceback (most recent call last):
File "/opt/airflow/scripts/in_container/is_provider_excluded.py", line 26, in
excluded_providers = json.loads(os.environ["EXCLUDED_PROVIDERS"])
File "/usr/local/lib/python3.9/os.py", line 679, in getitem
raise KeyError(key) from None
KeyError: 'EXCLUDED_PROVIDERS'

After:

Forcing dependencies to lowest versions for provider: [microsoft-azure]

Check if provider is excluded in {}
Provider is not excluded.

The current code throws a KeyError when the environment variable
EXCLUDED_PROVIDERS is not defind. This commit adds an empty map
as a default to prevent this failure.
@perry2of5
Copy link
Copy Markdown
Contributor Author

I don't recall requesting a review (although it seems reasonable). Is that an automated GitHub action? If so, it shouldn't show up as being from me!

@potiuk potiuk merged commit 5abdb7b into apache:main Oct 25, 2024
@potiuk
Copy link
Copy Markdown
Member

potiuk commented Oct 25, 2024

I don't recall requesting a review (although it seems reasonable). Is that an automated GitHub action? If so, it shouldn't show up as being from me!

It is how CODEOWNERS work

@perry2of5
Copy link
Copy Markdown
Contributor Author

Oh, okay. I didn't know about CODEOWNERS! Thank you.

@perry2of5 perry2of5 deleted the dflt-to-empty-map-when-env-var-not-defined branch October 25, 2024 17:25
ellisms pushed a commit to ellisms/airflow that referenced this pull request Nov 13, 2024
The current code throws a KeyError when the environment variable
EXCLUDED_PROVIDERS is not defind. This commit adds an empty map
as a default to prevent this failure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants