fix(cli): filter unknown --inputs keys even on flow persistence restore

Review follow-up: the `id` (persistence-restore) branch of
_resolve_flow_inputs returned the raw payload, so typo keys passed alongside
`id` skipped the unknown-key warning/drop and reached kickoff — which can
fail strict (extra="forbid") flow state models. The restore path now still
warns on and drops unknown keys (keeping `id` and known state fields); it
only skips the required-field prompt and pre-kickoff validation, which
persistence hydrates. Regression test: test_id_restore_still_drops_unknown_keys.

Also drop the duplicate module import in test_input_prompt.py (both `import`
and `from ... import` of crewai_cli.input_prompt) flagged by the code-quality
bot; monkeypatching now uses the string target form.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RBYGqJHC2TMC6fonFziuuh
This commit is contained in:
Joao Moura
2026-07-07 14:03:04 -07:00
parent 592d27f808
commit ae05160f48
3 changed files with 36 additions and 11 deletions

View File

@@ -4,7 +4,6 @@ from __future__ import annotations
import pytest
import crewai_cli.input_prompt as input_prompt_module
from crewai_cli.input_prompt import (
closest_name,
parse_inputs_json,
@@ -51,7 +50,7 @@ def test_prompt_for_inputs_uses_describe_and_coerce(monkeypatch, capsys):
seen.append(text)
return "42"
monkeypatch.setattr(input_prompt_module.click, "prompt", fake_prompt)
monkeypatch.setattr("crewai_cli.input_prompt.click.prompt", fake_prompt)
result = prompt_for_inputs(
["count"],
@@ -71,7 +70,7 @@ def test_prompt_for_inputs_uses_describe_and_coerce(monkeypatch, capsys):
def test_prompt_for_inputs_keeps_raw_string_without_coerce(monkeypatch):
monkeypatch.setattr(
input_prompt_module.click, "prompt", lambda text, **kwargs: "AI"
"crewai_cli.input_prompt.click.prompt", lambda text, **kwargs: "AI"
)
result = prompt_for_inputs(