Skip to content

Commit

Permalink
Look for extra__ instead of extra_ in get_field (#27489)
Browse files Browse the repository at this point in the history
This reduces likelihood of false positive.  It's not possible as currently used.  But if someone were to add an extra field `extra_info` for example, that would cause trouble avoided by this change.
  • Loading branch information
dstandish committed Nov 3, 2022
1 parent eb47c42 commit 680965b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion airflow/providers/grpc/hooks/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def run(
def _get_field(self, field_name: str):
"""Get field from extra, first checking short name, then for backcompat we check for prefixed name."""
backcompat_prefix = "extra__grpc__"
if field_name.startswith("extra_"):
if field_name.startswith("extra__"):
raise ValueError(
f"Got prefixed name {field_name}; please remove the '{backcompat_prefix}' prefix "
"when using this method."
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/jdbc/hooks/jdbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_ui_field_behaviour() -> dict[str, Any]:
def _get_field(self, extras: dict, field_name: str):
"""Get field from extra, first checking short name, then for backcompat we check for prefixed name."""
backcompat_prefix = "extra__jdbc__"
if field_name.startswith("extra_"):
if field_name.startswith("extra__"):
raise ValueError(
f"Got prefixed name {field_name}; please remove the '{backcompat_prefix}' prefix "
"when using this method."
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/microsoft/azure/hooks/wasb.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def __init__(

def _get_field(self, extra_dict, field_name):
prefix = "extra__wasb__"
if field_name.startswith("extra_"):
if field_name.startswith("extra__"):
raise ValueError(
f"Got prefixed name {field_name}; please remove the '{prefix}' prefix "
f"when using this method."
Expand Down

0 comments on commit 680965b

Please sign in to comment.