open-code-review/cmd/opencodereview
Xupeng 6546da9885
feat(provider): support custom Base URL for LiteLLM/built-in providers (#729)
* feat(provider): add editable Base URL step to official provider wizard

The official-provider tab in `ocr config provider` only captured API key
and model, with no way to override a preset provider's Base URL. The
resolver already honored `entry.URL` over `preset.BaseURL`, but the TUI
never exposed it — litellm (a self-hosted gateway rarely at
http://localhost:4000/v1) was the canonical pain point.

Add a Base URL step to the official-tab flow (stepModel -> stepBaseURL ->
stepAPIKey), pre-filled with the effective URL (configured override or
preset default). Persist `providers.<name>.url` only when the entered
value differs from the preset default, so the preset remains the fallback
and configs without an explicit url are unchanged. Custom/manual tabs are
unaffected.

Add resolver regression tests (litellm override + default fallback) and
TUI tests (pre-fill with preset/override, Esc navigation, persistence of
override vs. clearing on preset default). Update the four official-tab
tests that assumed stepModel -> stepAPIKey to traverse the new step.

* feat(provider): surface override Base URL in model picker and document it

With the wizard now able to set a Base URL override for built-in
providers, make the override visible and discoverable.

- `ocr config model` shows the effective Base URL for a preset provider
  (the configured `providers.<name>.url` override, or the preset default
  when none is set) so users can confirm their gateway is in use.
- The provider-wizard model-selection step shows the same effective URL
  via a tab-aware `effectiveBaseURL()` helper (official override/preset,
  or custom provider URL).
- Document `providers.<name>.url` as a built-in provider override in the
  configuration docs, with a litellm example and the preset-as-default
  semantics; note the wizard's editable Base URL step.

Add tests covering the model-selector display (override vs preset
default) and the wizard's effectiveBaseURL resolution.

* fix(provider): address PR review — URL trim, validation, dead code, Esc display

Address 4 of 5 code review findings on PR #729:

1. URL trim consistency (provider_cmd.go): trim the Base URL once and use
   the trimmed value for both comparison and persistence, preventing
   whitespace-polluted URLs from being written to config.

2. URL format validation (provider_cmd.go): validate that the Base URL
   has an http/https scheme and non-empty host before persisting, giving
   immediate feedback instead of a runtime failure. Rejects malformed
   values like bare hosts or ftp:// schemes.

3. Dead code removal (provider_tui.go): remove the init-time pre-fill of
   officialURLInput that is always overwritten by loadOfficialURL() when
   the user enters the Base URL step. Pre-fill logic now lives in a
   single place.

4. effectiveBaseURL reflects pending edit (provider_tui.go): when the
   user edits the Base URL and presses Esc back to model selection,
   effectiveBaseURL() now returns the in-progress value from
   officialURLInput instead of the stale on-disk config.

The SSRF/private-IP finding (#2 in review) is not addressed — it is a
false positive for a local CLI tool where localhost and private network
endpoints are the primary use case (the litellm preset default is
http://localhost:4000/v1).

* feat(provider): implement URL trimming and validation for provider configuration

* fix(provider): remove obsolete official URL handling

---------

Co-authored-by: Kite <254839944+lizhengfeng101@users.noreply.github.com>
2026-08-14 14:04:10 +08:00
..
apply_provider_field_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
arg_errors.go fix(cmd): report expected arguments when positional count is wrong (#892) 2026-08-13 20:44:04 +08:00
arg_errors_test.go fix(cmd): report expected arguments when positional count is wrong (#892) 2026-08-13 20:44:04 +08:00
background_file.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
background_file_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
budget_output_test.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00
compat_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
completion.go fix(cmd): report expected arguments when positional count is wrong (#892) 2026-08-13 20:44:04 +08:00
config_cmd.go feat(provider): support custom Base URL for LiteLLM/built-in providers (#729) 2026-08-14 14:04:10 +08:00
config_cmd_test.go feat(provider): support custom Base URL for LiteLLM/built-in providers (#729) 2026-08-14 14:04:10 +08:00
config_dispatch_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
config_runset_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
config_unset_error_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
delegate_cmd.go fix(cmd): report expected arguments when positional count is wrong (#892) 2026-08-13 20:44:04 +08:00
delegate_exec_test.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
delegate_helpers_test.go feat(cmd): add SARIF output format (#820) 2026-08-12 18:03:34 +08:00
emit_run_result_test.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00
flag_suggest.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
flag_suggest_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
flags_test.go feat(config): make per-file token limit configurable (#716) 2026-08-07 11:23:38 +08:00
git.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
git_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
llm_cmd.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00
main.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
manual_e2e_retry_test.go chore: remove Chinese doc references from retry test comments (#886) 2026-08-13 15:41:28 +08:00
misc_helpers_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
output.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00
output_helpers_test.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00
output_manifest_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
output_test.go chore(ci): fail CI when unapproved non-English text appears in source files (#876) 2026-08-13 14:43:55 +08:00
parent_cmd_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
procattr_unix.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
procattr_windows.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
provider_cmd.go feat(provider): support custom Base URL for LiteLLM/built-in providers (#729) 2026-08-14 14:04:10 +08:00
provider_cmd_test.go feat(provider): support custom Base URL for LiteLLM/built-in providers (#729) 2026-08-14 14:04:10 +08:00
provider_config_apply_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui.go feat(provider): support custom Base URL for LiteLLM/built-in providers (#729) 2026-08-14 14:04:10 +08:00
provider_tui_cpinput_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_customform_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_deleteconfirm_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_editsave_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_funcs_test.go feat(provider): support custom Base URL for LiteLLM/built-in providers (#729) 2026-08-14 14:04:10 +08:00
provider_tui_manualenter_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_modeltui_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_persist_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_rollback_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_savefail_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
provider_tui_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
retry_fake_llm_test.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00
retry_report_e2e_test.go chore: remove Chinese doc references from retry test comments (#886) 2026-08-13 15:41:28 +08:00
retry_report_render_test.go chore: remove Chinese doc references from retry test comments (#886) 2026-08-13 15:41:28 +08:00
review_cmd.go feat(resume): add trusted resume validation and transition lineage (#786) (#845) 2026-08-14 11:31:40 +08:00
review_cmd_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
review_helpers_test.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
review_mcp_more_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
review_resume_more_test.go feat(resume): add trusted resume validation and transition lineage (#786) (#845) 2026-08-14 11:31:40 +08:00
root.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
rules_check_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
rules_cmd.go fix(cmd): report expected arguments when positional count is wrong (#892) 2026-08-13 20:44:04 +08:00
sarif.go feat(cmd): add SARIF output format (#820) 2026-08-12 18:03:34 +08:00
sarif_test.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00
scan_cmd.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00
scan_cmd_test.go feat(config): make per-file token limit configurable (#716) 2026-08-07 11:23:38 +08:00
scan_helpers_test.go fix(cli): stop preview from creating a review session (#784) 2026-08-08 20:55:54 +08:00
scan_resume_more_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
session_cmd.go feat(resume): add trusted resume validation and transition lineage (#786) (#845) 2026-08-14 11:31:40 +08:00
session_cmd_test.go chore(ci): fail CI when unapproved non-English text appears in source files (#876) 2026-08-13 14:43:55 +08:00
session_complete_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
session_display_more_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
shared.go Feat/llm retry report:SDK retry-attempt observability for review (#785) (#790) 2026-08-13 14:31:18 +08:00
shared_flags.go feat(cmd): add SARIF output format (#820) 2026-08-12 18:03:34 +08:00
shared_llmruntime_test.go test: raise statement coverage to 90% and enforce it in CI (#747) 2026-08-06 12:55:44 +08:00
shared_test.go feat(config): make per-file token limit configurable (#716) 2026-08-07 11:23:38 +08:00
shell_unix.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
shell_windows.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
smallfiles_test.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
version.go fix(cli): reject unexpected positional arguments (#749) 2026-08-06 21:41:07 +08:00
viewer_cmd.go chore: add SPDX license headers and automated verification (#740) 2026-08-05 21:26:27 +08:00
zero_args_test.go fix(cli): reject unexpected positional arguments (#749) 2026-08-06 21:41:07 +08:00