Skip to content

Commit fb05a4f

Browse files
authored
Merge pull request #109 from forcedotcom/use-in-feature-fix-2
Revert --use-in-feature work and just use better error message
2 parents cb45864 + b6cfdd7 commit fb05a4f

2 files changed

Lines changed: 11 additions & 32 deletions

File tree

src/datacustomcode/cli.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,7 @@ 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-
)
201+
@click.option("--use-in-feature", default=None, hidden=True, deprecated=True)
206202
def deploy(
207203
path: str,
208204
name: str,
@@ -248,17 +244,20 @@ def deploy(
248244
)
249245

250246
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)
247+
# Infer use_in_feature from function signature
253248
entrypoint_path = os.path.join(path, ENTRYPOINT_FILE)
254-
inferred = infer_use_in_feature(entrypoint_path)
255-
if inferred:
256-
use_in_feature = inferred
249+
use_in_feature = infer_use_in_feature(entrypoint_path)
250+
if use_in_feature:
257251
logger.info(f"Inferred use_in_feature: {use_in_feature}")
258252
else:
259-
logger.info(f"Using use_in_feature: {use_in_feature}")
253+
click.secho(
254+
"Error: Function signature does not match a supported type. "
255+
"Use SearchIndexChunkingV1Request and "
256+
"SearchIndexChunkingV1Response in function signature.",
257+
fg="red",
258+
)
259+
raise click.Abort()
260260

261-
assert use_in_feature is not None
262261
# Map feature names to Connect API names
263262
mapped_feature = USE_IN_FEATURE_MAPPING_FOR_CONNECT_API.get(
264263
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)