Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions airflow/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,13 @@ def _sanitize_uri(uri: str) -> str:
parsed = normalizer(parsed)
except ValueError as exception:
if conf.getboolean("core", "strict_dataset_uri_validation", fallback=False):
raise exception
else:
warnings.warn(
f"The dataset URI {uri} is not AIP-60 compliant. "
f"In Airflow 3, this will raise an exception. More information: {repr(exception)}",
UserWarning,
stacklevel=3,
)
raise
warnings.warn(
f"The dataset URI {uri} is not AIP-60 compliant: {exception}. "
f"In Airflow 3, this will raise an exception.",
UserWarning,
stacklevel=3,
)
return urllib.parse.urlunsplit(parsed)


Expand Down
7 changes: 2 additions & 5 deletions tests/datasets/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,8 @@ def normalizer(uri):
def test__sanitize_uri_raises_warning(mock_warn):
_sanitize_uri("postgres://localhost:5432/database.schema.table")
msg = mock_warn.call_args.args[0]
assert "The dataset URI postgres://localhost:5432/database.schema.table is not AIP-60 compliant." in msg
assert (
"In Airflow 3, this will raise an exception. More information: ValueError('Incorrect URI format')"
in msg
)
assert "The dataset URI postgres://localhost:5432/database.schema.table is not AIP-60 compliant" in msg
assert "In Airflow 3, this will raise an exception." in msg


@patch("airflow.datasets._get_uri_normalizer", mock_get_uri_normalizer)
Expand Down