Skip to content

refactor(cli): clarify ProviderOptionsConfig and replace --reconfigure with --reset#471

Merged
skevetter merged 1 commit into
mainfrom
address-pr469-comments
May 31, 2026
Merged

refactor(cli): clarify ProviderOptionsConfig and replace --reconfigure with --reset#471
skevetter merged 1 commit into
mainfrom
address-pr469-comments

Conversation

@skevetter

@skevetter skevetter commented May 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Internal cleanup on the provider option-resolution surface plus a CLI rename to make the user-facing flag honest about its behavior.

Changes

  1. ReconfigureDiscardPriorValues on ProviderOptionsConfig. The old name sounded like "should we run init again?" (which SkipInit already controls); the flag actually toggles whether mergeExistingOptions seeds prompts with the user's previous answers.
  2. ContextContextName on ProviderOptionsConfig. The string field colliding with context.Context in ConfigureProvider(ctx context.Context, cfg ProviderOptionsConfig) was a readability hazard.
  3. Replaced --reconfigure with --reset on provider init. Same capability ("discard previously stored option answers and re-prompt"), name now describes what it does. The flag is gone from provider set — that command is for targeted -o KEY=VALUE edits and the "set this key AND re-prompt for everything else" combined behavior had no real use case.
  4. Dropped redundant log.Errorf on set-source failure — the wrapped fmt.Errorf("configure provider: %w", err) already conveys it.

Why

CodeRabbit on #469 suggested Reconfigure: true on provider set-source to prevent "stale data" leaking through mergeExistingOptions. Investigation showed the downstream resolver already prunes stale keys (pkg/options/resolver/resolver.go:153-157) and re-resolves values that fail validation (resolve.go:207-215). Forcing reconfigure would have re-prompted users for options whose values were still valid — UX regression, not a fix.

A code-review bot reaching for the wrong tool is strong evidence humans would too. The renames and the flag rename address the root cause: every name in the struct and on the CLI should describe what it does.

Call site audit (6 sites, all updated)

Call site DiscardPriorValues Rationale
provider add true (explicit) Fresh install — merge is a no-op; explicit for clarity
provider set-source omitted (zero) Preserve user values; resolver handles stale pruning
provider init cmd.Reset Bound to user-facing --reset flag
provider set omitted (zero) Always preserve; flag removed
pro update-provider true Automated version bump, re-resolves from defaults
pro login omitted (zero) Post-login refresh preserves values

Follow-up (separate PR)

Tests for ConfigureProvider's merge semantics — currently zero coverage. Three scenarios to lock down: (a) preserves user-provided values whose keys remain in the new schema, (b) DiscardPriorValues=true discards them, (c) keys absent from the new schema are pruned by the resolver regardless of this flag.

@netlify

netlify Bot commented May 31, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 17388b7
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a1c6896ceeb860008e00f7c

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. 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

Run ID: 9273b3b0-2398-4d88-a953-d9e7f0917268

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 and usage tips.

@skevetter
skevetter force-pushed the address-pr469-comments branch 2 times, most recently from fd34d79 to cba4d8a Compare May 31, 2026 16:45
@skevetter skevetter changed the title fix(cli): reconfigure provider options on 'set-source' refactor(cli): drop redundant error log on 'provider set-source' failure May 31, 2026
@skevetter
skevetter force-pushed the address-pr469-comments branch from cba4d8a to f501fd9 Compare May 31, 2026 16:48
@skevetter skevetter changed the title refactor(cli): drop redundant error log on 'provider set-source' failure refactor(cli): rename ProviderOptionsConfig.Reconfigure to DiscardPriorValues May 31, 2026
@github-actions github-actions Bot added size/m and removed size/xs labels May 31, 2026
@skevetter
skevetter force-pushed the address-pr469-comments branch from f501fd9 to 9d89a1b Compare May 31, 2026 16:51
@skevetter skevetter changed the title refactor(cli): rename ProviderOptionsConfig.Reconfigure to DiscardPriorValues refactor(cli): clarify ProviderOptionsConfig field names May 31, 2026
@skevetter
skevetter force-pushed the address-pr469-comments branch from 9d89a1b to c30f82b Compare May 31, 2026 16:55
@skevetter skevetter changed the title refactor(cli): clarify ProviderOptionsConfig field names refactor(cli): clarify ProviderOptionsConfig and drop --reconfigure flag May 31, 2026
…orValues

The 'Reconfigure' flag on ProviderOptionsConfig was opaque: it sounded
like "should we run init again?" (which is what SkipInit controls) but
actually toggled whether mergeExistingOptions seeds the new prompts with
the user's previous answers. CodeRabbit reading PR #469 reached for
'Reconfigure: true' on 'provider set-source' defensively, assuming it
prevented stale data leaking through the merge — but the downstream
resolver already prunes stale keys and re-resolves invalid values
regardless of this flag.

Renaming the internal field to DiscardPriorValues makes the mechanism
self-documenting at every call site:

  - cmd/provider/add.go: DiscardPriorValues=true (fresh install; no
    prior values to merge anyway, kept explicit for clarity)
  - cmd/provider/set_source.go: omitted (zero value); preserves prior
    values, resolver handles stale-key pruning
  - cmd/provider/init.go: bound to user-facing --reconfigure flag
  - cmd/provider/set.go: same
  - cmd/pro/update_provider.go: DiscardPriorValues=true (automated
    version bump, re-resolves from new schema defaults)
  - cmd/pro/login.go: omitted (zero value)

User-facing --reconfigure flags on 'provider init' and 'provider set'
keep their names; the rename is internal only.

Also drops the redundant log.Errorf on set-source failure (the wrapped
error already conveys the failure).

Originally proposed adding Reconfigure: true to set-source per
CodeRabbit feedback on #469; investigation showed that the resolver
(pkg/options/resolver/resolver.go:153-157 and resolve.go:207-215)
already prunes keys absent from the new schema and re-resolves values
that fail validation, so the original Reconfigure: false on
'provider update' was correct and the rename preserves that behavior
with clearer code.
@skevetter
skevetter force-pushed the address-pr469-comments branch from c30f82b to 17388b7 Compare May 31, 2026 16:57
@skevetter skevetter changed the title refactor(cli): clarify ProviderOptionsConfig and drop --reconfigure flag refactor(cli): clarify ProviderOptionsConfig and replace --reconfigure with --reset May 31, 2026
@skevetter
skevetter enabled auto-merge (squash) May 31, 2026 17:22
@skevetter
skevetter merged commit 9ca54e8 into main May 31, 2026
54 checks passed
@skevetter
skevetter deleted the address-pr469-comments branch May 31, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant