Skip to content

Commit 274aa41

Browse files
committed
fix(listen): fix three root causes of missing transcript output
1. Boolean options as API strings (listen command) Deepgram REST API rejects Python booleans — 'True' is not a valid value for punctuate/smart_format. The streaming path already used "true"/"false" strings correctly; the prerecorded path did not. 2. Flag options defaulting to None instead of False (plugin_manager) click.option() was created with default=arg.get("default") which returns None when the arg spec has no "default" key. Click then passes None in kwargs instead of False, breaking any command that passes flag values to Pydantic bool fields. 3. type=str applied to flag options (plugin_manager) Passing type=str to is_flag=True options causes Click to coerce the False default to the string "False" (truthy), making every unset flag appear active. Fixed by skipping type for flags entirely. The plugin_manager bugs (2+3) affected all 75 flag options across every command in the CLI. The fix is backward-compatible: None → False is still falsy, but now also passes Pydantic bool validation.
1 parent 982e644 commit 274aa41

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

packages/deepctl-cmd-listen/src/deepctl_cmd_listen/command.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,14 @@ def _prerecorded(
519519
)
520520

521521
# ── Build API options ──────────────────────────────────────────
522+
# Deepgram REST API requires lowercase string booleans ("true"/"false").
523+
# Python booleans (True/False) serialize as "True"/"False" and are
524+
# rejected with HTTP 400 INVALID_QUERY_PARAMETER.
522525
options: dict[str, Any] = {
523526
"model": model,
524527
"language": language,
525-
"smart_format": smart_format,
526-
"punctuate": punctuate,
528+
"smart_format": "true" if smart_format else "false",
529+
"punctuate": "true" if punctuate else "false",
527530
}
528531
if diarize:
529532
options["diarize"] = "true"

packages/deepctl-core/src/deepctl_core/plugin_manager.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,22 @@ def _add_command_arguments(
422422
for arg in reversed(arguments):
423423
if arg.get("is_option", False):
424424
# Add as option
425-
cmd = click.option(
426-
*arg.get("names", []),
427-
default=arg.get("default"),
428-
help=arg.get("help", ""),
429-
type=arg.get("type", str),
430-
required=arg.get("required", False),
431-
is_flag=arg.get("is_flag", False),
432-
multiple=arg.get("multiple", False),
433-
)(cmd)
425+
is_flag = arg.get("is_flag", False)
426+
# Flags default to False (not None) so Click passes the
427+
# right type. Also skip `type` for flags — Click manages
428+
# its own bool type for flags; passing type=str converts
429+
# the False default to the string "False" which is truthy.
430+
default_fallback = False if is_flag else None
431+
option_kwargs: dict[str, Any] = {
432+
"default": arg.get("default", default_fallback),
433+
"help": arg.get("help", ""),
434+
"required": arg.get("required", False),
435+
"is_flag": is_flag,
436+
"multiple": arg.get("multiple", False),
437+
}
438+
if not is_flag:
439+
option_kwargs["type"] = arg.get("type", str)
440+
cmd = click.option(*arg.get("names", []), **option_kwargs)(cmd)
434441
else:
435442
# Add as argument
436443
cmd = click.argument(

0 commit comments

Comments
 (0)