Skip to content

Commit eda89a4

Browse files
committed
Revert --use-in-feature work and just use better error message
1 parent 87f5b73 commit eda89a4

2 files changed

Lines changed: 10 additions & 33 deletions

File tree

src/datacustomcode/cli.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,6 @@ def zip(path: str, network: str):
198198
default=None,
199199
help="SF CLI org alias or username. Fetches credentials via `sf org display`.",
200200
)
201-
@click.option(
202-
"--use-in-feature",
203-
default="SearchIndexChunking",
204-
help="Feature where this function will be used.",
205-
)
206201
def deploy(
207202
path: str,
208203
name: str,
@@ -212,7 +207,6 @@ def deploy(
212207
profile: str,
213208
network: str,
214209
sf_cli_org: Optional[str],
215-
use_in_feature: Optional[str],
216210
):
217211
from datacustomcode.constants import USE_IN_FEATURE_MAPPING_FOR_CONNECT_API
218212
from datacustomcode.deploy import (
@@ -248,17 +242,20 @@ def deploy(
248242
)
249243

250244
if package_type == "function":
251-
# Try to infer use_in_feature from function signature; fall back to
252-
# the explicit flag value (defaults to SearchIndexChunking)
245+
# Infer use_in_feature from function signature
253246
entrypoint_path = os.path.join(path, ENTRYPOINT_FILE)
254-
inferred = infer_use_in_feature(entrypoint_path)
255-
if inferred:
256-
use_in_feature = inferred
247+
use_in_feature = infer_use_in_feature(entrypoint_path)
248+
if use_in_feature:
257249
logger.info(f"Inferred use_in_feature: {use_in_feature}")
258250
else:
259-
logger.info(f"Using use_in_feature: {use_in_feature}")
251+
click.secho(
252+
"Error: Function signature does not match a supported type. "
253+
"Use SearchIndexChunkingV1Request and "
254+
"SearchIndexChunkingV1Response in function signature.",
255+
fg="red",
256+
)
257+
raise click.Abort()
260258

261-
assert use_in_feature is not None
262259
# Map feature names to Connect API names
263260
mapped_feature = USE_IN_FEATURE_MAPPING_FOR_CONNECT_API.get(
264261
use_in_feature, use_in_feature

tests/test_sf_cli_contract.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -188,26 +188,6 @@ def test_accepts_network_flag(
188188
result = runner.invoke(deploy, [*self._BASE_ARGS, "--network", "custom"])
189189
assert result.exit_code != 2, result.output
190190

191-
@patch("datacustomcode.token_provider.SFCLITokenProvider")
192-
@patch("datacustomcode.deploy.deploy_full")
193-
@patch("datacustomcode.cli.find_base_directory")
194-
@patch("datacustomcode.cli.get_package_type")
195-
def test_accepts_use_in_feature_flag(
196-
self, mock_pkg_type, mock_find_base, mock_deploy_full, mock_sf_cli_provider
197-
):
198-
mock_find_base.return_value = "payload"
199-
mock_pkg_type.return_value = "function"
200-
mock_provider_instance = mock_sf_cli_provider.return_value
201-
mock_provider_instance.get_token.return_value = AccessTokenResponse(
202-
access_token="tok", instance_url="https://example.com"
203-
)
204-
runner = CliRunner()
205-
result = runner.invoke(
206-
deploy,
207-
[*self._BASE_ARGS, "--use-in-feature", "SearchIndexChunking"],
208-
)
209-
assert result.exit_code != 2, result.output
210-
211191

212192
class TestRunArgContract:
213193
"""

0 commit comments

Comments
 (0)