diff --git a/conda/base/context.py b/conda/base/context.py index 0fd8f8cf7d0..2951f69cdb7 100644 --- a/conda/base/context.py +++ b/conda/base/context.py @@ -954,9 +954,7 @@ def channels(self): raise OperationNotAllowed("Overriding channels has been disabled.") if cli_channels: - return check_channel_allowlist( - IndexedSet((*local_channels, *cli_channels)) - ) + return validate_channels(IndexedSet((*local_channels, *cli_channels))) else: from ..exceptions import ArgumentError @@ -976,7 +974,7 @@ def channels(self): ) if cli_channels and not channel_in_config_files: _warn_defaults_deprecation() - return check_channel_allowlist( + return validate_channels( IndexedSet((*local_channels, *cli_channels, DEFAULTS_CHANNEL_NAME)) ) @@ -986,7 +984,7 @@ def channels(self): _warn_defaults_deprecation() channels = [DEFAULTS_CHANNEL_NAME] - return check_channel_allowlist(IndexedSet((*local_channels, *channels))) + return validate_channels(IndexedSet((*local_channels, *channels))) @property def config_files(self): @@ -2057,12 +2055,12 @@ def locate_prefix_by_name(name, envs_dirs=None): raise EnvironmentNameNotFound(name) -def check_channel_allowlist(channels: Iterator[str]) -> None: +def validate_channels(channels: Iterator[str]) -> None: """ - Check if the given channel URLs are allowed by the context's allowlist - and denylist. + Validate if the given channel URLs are allowed based on the context's allowlist + and denylist configurations. - :param channels: A list of channels (either URLs or names) to check against the allowlist. + :param channels: A list of channels (either URLs or names) to validate. :raises ChannelNotAllowed: If any URL is not in the allowlist. :raises ChannelDenied: If any URL is in the denylist. """ @@ -2093,6 +2091,8 @@ def check_channel_allowlist(channels: Iterator[str]) -> None: ): raise ChannelNotAllowed(channel) + return tuple(channels) + def validate_prefix_name(prefix_name: str, ctx: Context, allow_base=True) -> str: """Run various validations to make sure prefix_name is valid""" diff --git a/conda/core/index.py b/conda/core/index.py index a58b19ace78..380cadf0bc1 100644 --- a/conda/core/index.py +++ b/conda/core/index.py @@ -11,7 +11,7 @@ from boltons.setutils import IndexedSet -from ..base.context import check_channel_allowlist, context +from ..base.context import validate_channels, context from ..common.io import ThreadLimitedThreadPoolExecutor, time_recorder from ..deprecations import deprecated from ..exceptions import ( @@ -42,7 +42,7 @@ @deprecated( "25.9", "26.3", - addendum="Use `conda.base.context.check_channel_alllowlist` instead.", + addendum="Use `conda.base.context.validate_channels` instead.", ) def check_allowlist(channel_urls: list[str]) -> None: """ @@ -51,7 +51,7 @@ def check_allowlist(channel_urls: list[str]) -> None: :raises ChannelNotAllowed: If any URL is not in the allowlist. :raises ChannelDenied: If any URL is in the denylist. """ - check_channel_allowlist(channel_urls) + validate_channels(channel_urls) class Index(UserDict): diff --git a/news/14405-bugfix-for-denylist-channels b/news/14405-bugfix-for-denylist-channels index 9de1a8fa795..1b54ec0ef34 100644 --- a/news/14405-bugfix-for-denylist-channels +++ b/news/14405-bugfix-for-denylist-channels @@ -4,7 +4,7 @@ ### Bug fixes -* Fixes a bug where the setting `denylist_channels` was not being recognized in certain cases (#14405) +* Fix a bug where the setting `denylist_channels` was not being recognized in certain cases. (#14405) ### Deprecations