fix: explain draft set-input local targets
This commit is contained in:
@@ -62,6 +62,19 @@ def _parse_output_map_flags(values: list[str] | None) -> dict[str, str]:
|
|||||||
return parsed
|
return parsed
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_step_input_map_flags(values: list[str] | None) -> dict[str, str]:
|
||||||
|
"""Parse graph-source to bare-local input mappings for one draft step."""
|
||||||
|
parsed = _parse_map_flags(values)
|
||||||
|
for source, target in parsed.items():
|
||||||
|
if target.startswith("local."):
|
||||||
|
bare_target = target.removeprefix("local.")
|
||||||
|
raise typer.BadParameter(
|
||||||
|
"--map target must be a bare local field; "
|
||||||
|
f"use {source}={bare_target}, not {source}={target}"
|
||||||
|
)
|
||||||
|
return parsed
|
||||||
|
|
||||||
|
|
||||||
def _parse_route_flags(values: list[str] | None) -> dict[str, str]:
|
def _parse_route_flags(values: list[str] | None) -> dict[str, str]:
|
||||||
return _parse_assignment_flags(
|
return _parse_assignment_flags(
|
||||||
values,
|
values,
|
||||||
@@ -263,10 +276,13 @@ def set_step_input_map(
|
|||||||
--map entries in one command for a complete replacement. Use --merge only
|
--map entries in one command for a complete replacement. Use --merge only
|
||||||
when adding or updating entries across a later revision.
|
when adding or updating entries across a later revision.
|
||||||
|
|
||||||
|
Targets are bare node-local field names. Use `--map input.text=text`, not
|
||||||
|
`--map input.text=local.text`.
|
||||||
|
|
||||||
Run `wf draft validate <workspace_id>` after map edits; validation reports
|
Run `wf draft validate <workspace_id>` after map edits; validation reports
|
||||||
unresolved paths and conflicting writes.
|
unresolved paths and conflicting writes.
|
||||||
"""
|
"""
|
||||||
input_map = _parse_map_flags(mapping)
|
input_map = _parse_step_input_map_flags(mapping)
|
||||||
context = load_cli_context(ctx)
|
context = load_cli_context(ctx)
|
||||||
emit_json(
|
emit_json(
|
||||||
run_cli_operation(
|
run_cli_operation(
|
||||||
|
|||||||
@@ -153,6 +153,8 @@ def test_wf_draft_map_help_explains_replace_merge_and_validate() -> None:
|
|||||||
assert "replaces the full input map" in input_help
|
assert "replaces the full input map" in input_help
|
||||||
assert "Use --merge only" in input_help
|
assert "Use --merge only" in input_help
|
||||||
assert "draft validate" in input_help
|
assert "draft validate" in input_help
|
||||||
|
assert "input.text=text" in input_help
|
||||||
|
assert "input.text=local.text" in input_help
|
||||||
assert "replaces the full output map" in output_help
|
assert "replaces the full output map" in output_help
|
||||||
assert "Use --merge only" in output_help
|
assert "Use --merge only" in output_help
|
||||||
assert "draft validate" in output_help
|
assert "draft validate" in output_help
|
||||||
@@ -254,3 +256,26 @@ def test_wf_draft_route_flags_reject_duplicate_outcomes() -> None:
|
|||||||
assert branch_result.exit_code == 2
|
assert branch_result.exit_code == 2
|
||||||
assert "duplicate --route for 'ok'" in add_result.output
|
assert "duplicate --route for 'ok'" in add_result.output
|
||||||
assert "duplicate --route for 'ok'" in branch_result.output
|
assert "duplicate --route for 'ok'" in branch_result.output
|
||||||
|
|
||||||
|
|
||||||
|
def test_wf_draft_set_input_rejects_local_prefixed_target() -> None:
|
||||||
|
result = runner.invoke(
|
||||||
|
app,
|
||||||
|
[
|
||||||
|
"draft",
|
||||||
|
"set-input",
|
||||||
|
"report_ws",
|
||||||
|
"--revision",
|
||||||
|
"1",
|
||||||
|
"--step",
|
||||||
|
"render",
|
||||||
|
"--map",
|
||||||
|
"input.text=local.text",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result.exit_code == 2
|
||||||
|
output = " ".join(result.output.split())
|
||||||
|
assert "bare local field" in output
|
||||||
|
assert "input.text=text" in output
|
||||||
|
assert "input.text=local.text" in output
|
||||||
|
|||||||
Reference in New Issue
Block a user