From eda89a4c9e9a9e7506e840cce8508efffa3532ec Mon Sep 17 00:00:00 2001 From: Mark DeLaVergne Date: Thu, 4 Jun 2026 10:49:37 -0400 Subject: [PATCH 1/2] Revert --use-in-feature work and just use better error message --- src/datacustomcode/cli.py | 23 ++++++++++------------- tests/test_sf_cli_contract.py | 20 -------------------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/src/datacustomcode/cli.py b/src/datacustomcode/cli.py index e283995..cfc7175 100644 --- a/src/datacustomcode/cli.py +++ b/src/datacustomcode/cli.py @@ -198,11 +198,6 @@ def zip(path: str, network: str): default=None, help="SF CLI org alias or username. Fetches credentials via `sf org display`.", ) -@click.option( - "--use-in-feature", - default="SearchIndexChunking", - help="Feature where this function will be used.", -) def deploy( path: str, name: str, @@ -212,7 +207,6 @@ def deploy( profile: str, network: str, sf_cli_org: Optional[str], - use_in_feature: Optional[str], ): from datacustomcode.constants import USE_IN_FEATURE_MAPPING_FOR_CONNECT_API from datacustomcode.deploy import ( @@ -248,17 +242,20 @@ def deploy( ) if package_type == "function": - # Try to infer use_in_feature from function signature; fall back to - # the explicit flag value (defaults to SearchIndexChunking) + # Infer use_in_feature from function signature entrypoint_path = os.path.join(path, ENTRYPOINT_FILE) - inferred = infer_use_in_feature(entrypoint_path) - if inferred: - use_in_feature = inferred + use_in_feature = infer_use_in_feature(entrypoint_path) + if use_in_feature: logger.info(f"Inferred use_in_feature: {use_in_feature}") else: - logger.info(f"Using use_in_feature: {use_in_feature}") + click.secho( + "Error: Function signature does not match a supported type. " + "Use SearchIndexChunkingV1Request and " + "SearchIndexChunkingV1Response in function signature.", + fg="red", + ) + raise click.Abort() - assert use_in_feature is not None # Map feature names to Connect API names mapped_feature = USE_IN_FEATURE_MAPPING_FOR_CONNECT_API.get( use_in_feature, use_in_feature diff --git a/tests/test_sf_cli_contract.py b/tests/test_sf_cli_contract.py index 61f7f15..f53123e 100644 --- a/tests/test_sf_cli_contract.py +++ b/tests/test_sf_cli_contract.py @@ -188,26 +188,6 @@ def test_accepts_network_flag( result = runner.invoke(deploy, [*self._BASE_ARGS, "--network", "custom"]) assert result.exit_code != 2, result.output - @patch("datacustomcode.token_provider.SFCLITokenProvider") - @patch("datacustomcode.deploy.deploy_full") - @patch("datacustomcode.cli.find_base_directory") - @patch("datacustomcode.cli.get_package_type") - def test_accepts_use_in_feature_flag( - self, mock_pkg_type, mock_find_base, mock_deploy_full, mock_sf_cli_provider - ): - mock_find_base.return_value = "payload" - mock_pkg_type.return_value = "function" - mock_provider_instance = mock_sf_cli_provider.return_value - mock_provider_instance.get_token.return_value = AccessTokenResponse( - access_token="tok", instance_url="https://example.com" - ) - runner = CliRunner() - result = runner.invoke( - deploy, - [*self._BASE_ARGS, "--use-in-feature", "SearchIndexChunking"], - ) - assert result.exit_code != 2, result.output - class TestRunArgContract: """ From b6cfdd798d963f8d282b6ad7d4fbd8dfc3592f71 Mon Sep 17 00:00:00 2001 From: Mark DeLaVergne Date: Thu, 4 Jun 2026 11:11:29 -0400 Subject: [PATCH 2/2] Keep a deprecated version of --use-in-feature for SF CLI integration --- src/datacustomcode/cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/datacustomcode/cli.py b/src/datacustomcode/cli.py index cfc7175..7e2cd00 100644 --- a/src/datacustomcode/cli.py +++ b/src/datacustomcode/cli.py @@ -198,6 +198,7 @@ def zip(path: str, network: str): default=None, help="SF CLI org alias or username. Fetches credentials via `sf org display`.", ) +@click.option("--use-in-feature", default=None, hidden=True, deprecated=True) def deploy( path: str, name: str, @@ -207,6 +208,7 @@ def deploy( profile: str, network: str, sf_cli_org: Optional[str], + use_in_feature: Optional[str], ): from datacustomcode.constants import USE_IN_FEATURE_MAPPING_FOR_CONNECT_API from datacustomcode.deploy import (