Prevent --json from prompting interactively on a 403

Per review: --json still went through _create_host_backend_client
and _call_host_backend_with_optional_tenant, both of which prompt
interactively (writing to stdout, reading stdin) when the module-
level _no_input flag is left at its default False. deploy_listeners_
list never set it, unlike the main deploy command, so a missing API
key or an org-scoped key without LANGSMITH_TENANT_ID would corrupt
the JSON output with warning text and could hang waiting for input
that a scripted invocation never provides.

Sets _no_input = json_output at the top of the command, same pattern
_deploy_cmd already uses, so both paths raise a ClickException to
stderr instead. Added a regression test that fails without the fix
(click.prompt is genuinely invoked) and passes with it.
This commit is contained in:
gdibben
2026-10-08 08:26:40 +01:00
parent 48b2346e33
commit 6b84ae69a0
2 changed files with 55 additions and 0 deletions
+2
View File
@@ -2536,6 +2536,8 @@ def deploy_listeners() -> None:
def deploy_listeners_list(
api_key: str | None, host_url: str | None, json_output: bool
) -> None:
global _no_input
_no_input = json_output
client = _create_host_backend_client(host_url, api_key)
listeners = _call_host_backend_with_optional_tenant(
client, lambda c: c.list_listeners()