Skip to content

refactor(config): consolidate command-family helpers (CLI-2292) - #6491

Merged
Coly010 merged 4 commits into
developfrom
columferry/cli-2292-config-command-family-cleanup-shared-pathvalue-helpers-error
Sep 7, 2026
Merged

Coly010 merged 4 commits into
developfrom
columferry/cli-2292-config-command-family-cleanup-shared-pathvalue-helpers-error

Conversation

@Coly010

@Coly010 Coly010 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Current Behavior

Follow-up debt recorded by the CLI-2064 architecture review (explicitly ruled a follow-up, not a pre-merge fix):

  1. pathKey has separate definitions across the config command family's pull/ modules; deepEqualValue/valueAtPath/isDeclaredAtPath are each implemented twice (pull.plan.ts); deepSetAtPath is a third deep-set concept, only reachable through the planner.
  2. LegacyConfigTargetErrors<A,B,C,D,E> in config.target.ts hand-injects five generic constructors per command, and reclassifies a 404 via a Predicate.hasProperty("status") duck-type check.
  3. config diff and config pull render change classes through a shared label map in config.format.ts.
  4. config-edit.ts's [remotes.<label>] placement logic hardcodes the "remotes"/"project_id" literals inline at each use site.

Expected Behavior

  1. One config.paths.ts at the command family root holds the shared path/value helpers; the three pull/ modules that duplicated them now import from it. config-edit.ts (in @supabase/config, pinned to smol-toml as its only import per ADR 0023) keeps its own independent copies — deliberately out of scope.
  2. config.target.ts now mints each family's four target-resolution error classes from a prefix (legacyMintConfigTargetErrors) and builds their shared message-template bundle in one place (legacyConfigTargetErrorsFor), collapsing LegacyConfigTargetErrors/legacyResolveConfigTarget from five generics to two and replacing the duck-typed 404 check with a typed LegacyConfigTargetResolveFailure bound. diff, pull, and push now all route through this factory — push adopted the shared resolver since the CLI-2064 review, meeting the precondition this item was waiting on.
  3. Already done in feat(cli): rebuild config push as diff-first partial updates (CLI-2313) #6454 (CLI-2313) — diff.format.ts already renders through config.format.ts's shared label map. No changes needed; confirmed while implementing this issue.
  4. config-edit.ts now names the two literals (REMOTES_TABLE_NAME, REMOTE_PROJECT_ID_KEY) and a shared isRemotesLabelRoot predicate next to the doc comment that already describes the exception.

No user-observable behavior changes — every renamed/relocated helper keeps its exact prior implementation, and the four minted error classes keep their original tags, actionability, and message text (verified against the existing diff/pull/push integration test suites and the error-actionability-coverage drift guard).

…lasses (CLI-2292)

Follow-up debt from the CLI-2064 architecture review: `pull/`'s three
pathKey/valueAtPath/isDeclaredAtPath/deepEqualValue/deepSetAtPath copies
collapse into one config.paths.ts; config.target.ts's 5-generic
LegacyConfigTargetErrors<A,B,C,D,E> becomes a per-family error-class
factory now that diff/pull/push all share it, dropping the
Predicate.hasProperty duck-typed 404 reclassification for a typed bound;
and config-edit.ts's hardcoded "remotes"/"project_id" placement literals
get named constants. The config-label unification this issue also asked
for already landed in CLI-2313 (#6454).

Fixes CLI-2292
@Coly010
Coly010 requested a review from a team as a code owner September 7, 2026 10:14
@Coly010 Coly010 self-assigned this Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@f943cfdc9da96db98a110bd5411c6066f58a75b6

Preview package for commit f943cfd.

…config-command-family-cleanup-shared-pathvalue-helpers-error

# Conflicts:
#	apps/cli/src/commands/config/diff/diff.handler.ts
#	apps/cli/src/commands/config/pull/pull.handler.ts

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

Both independent reviews were available. Codex reported no findings; Claude reported five. Code inspection confirms all five: two minor consolidation/guard concerns and three nits involving comments, edge-case tests, and type ergonomics. No user-breaking behavioral regression was identified.

Findings

Severity Location Category Sources Claim
🟡 MINOR apps/cli/src/commands/config/config.paths.ts:24 duplication claude The new shared record predicate remains duplicated in two config-family modules, contrary to the repository's hoist-before-duplication convention, and the header's stated non-consolidations do not account for those copies.
🟡 MINOR apps/cli/src/commands/config/config.target.ts:70 test-coverage claude Template-interpolating the 12 generated error tags removes them from the static actionability scan, while their runtime coverage now depends on each family errors module continuing to contain an unrelated literal-tagged error.
⚪ NIT apps/cli/src/commands/config/diff/diff.handler.ts:155 documentation claude The diff and pull target-resolution comments still describe sharing only with each other, omitting config push.
⚪ NIT apps/cli/src/commands/config/config.paths.unit.test.ts:42 test-coverage claude The new tests do not distinguish own-property lookup from inherited-property lookup and omit the empty-path and existing-scalar replacement semantics of legacyConfigDeepSetAtPath.
⚪ NIT apps/cli/src/commands/config/diff/diff.errors.ts:46 api-design claude Changing the 12 exported error classes to const constructor aliases removes their direct type-position usability.

Stats

Claude findings: 5 · Codex findings: 0 · Confirmed: 5 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5 + gpt-5.6-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread apps/cli/src/commands/config/config.paths.ts
Comment thread apps/cli/src/commands/config/config.target.ts
Comment thread apps/cli/src/commands/config/diff/diff.handler.ts Outdated
Comment thread apps/cli/src/commands/config/config.paths.unit.test.ts
Comment thread apps/cli/src/commands/config/diff/diff.errors.ts
Hoists diff.handler.ts's and push.paths.ts's remaining isRecord copies onto
config.paths.ts's legacyConfigIsRecord, restores type-position usability
for the 12 minted target-error class names via companion InstanceType
aliases, and calls out config push in the two target-resolution doc
comments that still only named diff/pull. Adds a dedicated
config.target.unit.test.ts covering legacyMintConfigTargetErrors'
tags/actionability independent of any family's own errors file, plus
inherited-key and deep-set edge cases to config.paths.unit.test.ts.
@Coly010
Coly010 added this pull request to the merge queue Sep 7, 2026
Merged via the queue into develop with commit 8773536 Sep 7, 2026
26 checks passed
@Coly010
Coly010 deleted the columferry/cli-2292-config-command-family-cleanup-shared-pathvalue-helpers-error branch September 7, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants