Skip to content

[Feature] TH Project Config Editor - #112

Open
antonio-amjr wants to merge 2 commits into
project-chip:v2.16-cli-developfrom
antonio-amjr:feature/th_config_update_with_editor
Open

[Feature] TH Project Config Editor#112
antonio-amjr wants to merge 2 commits into
project-chip:v2.16-cli-developfrom
antonio-amjr:feature/th_config_update_with_editor

Conversation

@antonio-amjr

Copy link
Copy Markdown
Contributor

Fix: project-chip/certification-tool#1094

Description

  • Adds th-cli project edit --id <ID>, which opens the project's config JSON in the user's $EDITOR/$VISUAL (via click.edit()), validates it on save, and persists it through the existing PUT /api/v1/projects/{id} endpoint — closing the gap where patching a single field required a full export/edit/re-import cycle or the execution-only run-tests --prompt-timeout override.
  • Adds a client-side guard that recursively diffs the edited config's keys against the original and asks for confirmation before saving if new/unknown keys were introduced, since the backend (pydantic v1, no extra = "forbid") silently drops unknown fields outside dut_config rather than rejecting them.
  • On invalid JSON or a 422 from the server, the editor reopens with the user's last edit preserved (bounded to 3 attempts) instead of discarding their work.
  • Documents $EDITOR/$VISUAL selection behavior in the README.

Changes

  • th_cli/commands/project.py: new edit command and _edit_project() implementation, plus helpers _collect_dotted_keys, _strip_error_banner, _build_json_error_banner/_build_backend_error_banner, _format_422_detail (handles both the string-detail and list-of-errors detail shapes the 422 response can take).
  • tests/test_project_commands.py: 16 new tests covering the happy path, abort paths (no save / no changes), retry exhaustion for both invalid JSON and repeated 422s, the new-key confirmation prompt (accept/decline, top-level and nested), 422 formatting for both body shapes, non-retryable errors (404), and help/argument validation.
  • README.md: documents the edit-project command and how to override the editor via $EDITOR/$VISUAL.

Test plan

  • Unit Tests passing
  • Manual smoke test against a running backend: th-cli project edit --id <id>, confirm the editor opens pre-filled with the current config, make a valid change and save, confirm it persists
  • Manual test: introduce a typo'd new key → confirm the warning/confirmation prompt fires
  • Manual test: save invalid JSON → confirm the editor reopens with the error banner and prior content intact

@antonio-amjr antonio-amjr self-assigned this Aug 28, 2026
@antonio-amjr antonio-amjr added the enhancement New feature or request label Aug 28, 2026
@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b6202887-3069-4aa7-b9a6-ac699aa033e5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify

mergify Bot commented Aug 28, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@rquidute

Copy link
Copy Markdown
Contributor

@antonio-amjr Please also update the user guide accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants