-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Remove core references in secrets backend logic in sdk #59597
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
Merged
amoghrajesh
merged 6 commits into
apache:main
from
astronomer:remove-dependency-on-constant
Jan 9, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2ba485f
Move default secrets backend lookup order to shared library to decoup…
amoghrajesh 23bf9d9
Remove core references in secrets backend logic in sdk
amoghrajesh 53de34b
Merge branch 'main' into remove-dependency-on-constant
amoghrajesh a315cdb
fixes
amoghrajesh 7fd3458
fixes
amoghrajesh e1dd7cc
add prek hook to catch mismatch
amoghrajesh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| #!/usr/bin/env python | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
| from __future__ import annotations | ||
|
|
||
| import ast | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| AIRFLOW_ROOT = Path(__file__).parents[3].resolve() | ||
| CORE_SECRETS_FILE = AIRFLOW_ROOT / "airflow-core" / "src" / "airflow" / "secrets" / "base_secrets.py" | ||
| SDK_SECRETS_FILE = ( | ||
| AIRFLOW_ROOT / "task-sdk" / "src" / "airflow" / "sdk" / "execution_time" / "secrets" / "__init__.py" | ||
| ) | ||
|
|
||
|
|
||
| def extract_from_file(file_path: Path, constant_name: str) -> list[str] | None: | ||
| """Extract a list constant value from a Python file using AST parsing.""" | ||
| try: | ||
| with open(file_path) as f: | ||
| tree = ast.parse(f.read(), filename=str(file_path)) | ||
|
|
||
| for node in ast.walk(tree): | ||
| if isinstance(node, ast.Assign): | ||
| for target in node.targets: | ||
| if isinstance(target, ast.Name) and target.id == constant_name: | ||
| if isinstance(node.value, ast.List): | ||
| values = [] | ||
| for elt in node.value.elts: | ||
| if isinstance(elt, ast.Constant): | ||
| values.append(elt.value) | ||
| return values | ||
| return None | ||
| except Exception as e: | ||
| print(f"Error parsing {file_path}: {e}", file=sys.stderr) | ||
| return None | ||
|
|
||
|
|
||
| def main() -> None: | ||
| # Extract DEFAULT_SECRETS_SEARCH_PATH from airflow-core | ||
| core_path = extract_from_file(CORE_SECRETS_FILE, "DEFAULT_SECRETS_SEARCH_PATH") | ||
| if core_path is None: | ||
| print( | ||
| f"ERROR: Could not extract DEFAULT_SECRETS_SEARCH_PATH from {CORE_SECRETS_FILE}", | ||
| file=sys.stderr, | ||
| ) | ||
| sys.exit(1) | ||
|
|
||
| # Extract _SERVER_DEFAULT_SECRETS_SEARCH_PATH from task-sdk | ||
| sdk_path = extract_from_file(SDK_SECRETS_FILE, "_SERVER_DEFAULT_SECRETS_SEARCH_PATH") | ||
| if sdk_path is None: | ||
| print( | ||
| f"ERROR: Could not extract _SERVER_DEFAULT_SECRETS_SEARCH_PATH from {SDK_SECRETS_FILE}", | ||
| file=sys.stderr, | ||
| ) | ||
| sys.exit(1) | ||
|
|
||
| if core_path == sdk_path: | ||
| sys.exit(0) | ||
| else: | ||
| print("\nERROR: Secrets search paths are not synchronized!", file=sys.stderr) | ||
| print( | ||
| "\nThe DEFAULT_SECRETS_SEARCH_PATH in airflow-core and " | ||
| "_SERVER_DEFAULT_SECRETS_SEARCH_PATH in task-sdk must match.", | ||
| file=sys.stderr, | ||
| ) | ||
| print("\nPlease update either:", file=sys.stderr) | ||
| print(f" - {CORE_SECRETS_FILE}", file=sys.stderr) | ||
| print(f" - {SDK_SECRETS_FILE}", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.