Skip to content

refactor(upgrade-config): list Validation profiles through the Task catalog - #240

Open
jackchuma wants to merge 2 commits into
mainfrom
refactor/profile-listing-task-catalog
Open

jackchuma wants to merge 2 commits into
mainfrom
refactor/profile-listing-task-catalog

Conversation

@jackchuma

@jackchuma jackchuma commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Linear: https://linear.app/coinbase/issue/CHAIN-6507/validation-profile-listing-through-the-task-catalog

What changed? Why?

The profile listing route built Task paths and ran its own id and path checks. Those now live in the Task catalog, which gains listProfiles(taskId, network). The route is a thin wrapper, and it no longer imports @/lib/deployments, which unblocks deleting that module (CHAIN-6510).

 GET /api/upgrade-config
-  regex check, path.join, assertWithinDir, fs.readdir, ENOENT → 200 []
+  defaultTaskCatalog().listProfiles(upgradeId, network)
+  errorResponse: invalid-id → 400, outside-root → 403, not-found → 404, else 500
  • listProfiles returns { name, displayName }[] for the .json files in config/<network>/validations, sorted by name. It never reads file contents, so a malformed Validation profile is still listed and fails later at validation.
  • The response is { configOptions: [{ name, displayName }] }. ConfigOption.fileName is renamed to name to match. No components or props are renamed.

Notes to reviewers

  • Start with listProfiles in src/lib/task-catalog.ts, then errorResponse in the route.
  • Behavior change: a missing Task or missing validations directory now returns 404 instead of 200 with an empty list (parent CHAIN-6504, story 4). The UI only offers Tasks that have a validations directory, so a user only reaches this through a race.
  • #227 already removed file parsing and ledgerId from this route. This PR pins both with exact-equality tests.
  • Reversibility: git revert undoes it. Blast radius: the profile picker in this app only.

How has it been tested?

Tests run the real catalog on temp-dir fixture trees, with no fs mocks:

  • Catalog: listing (only .json, sorted, display names), a malformed file, invalid ids, symlinks escaping the root, a missing Task or validations directory (not-found), and other fs errors propagating unchanged.
  • Route: 400 missing param, 400 invalid id, 403 outside root, 404 missing Task, 500 other error, and the exact response shape.

Before: the new catalog tests failed with listProfiles missing or a raw ENOENT where a TaskCatalogError was expected. The route tests failed with 500 where 400/403/404 were expected, and with an empty configOptions where profiles were expected.

After: npm test -- --runTestsByPath src/lib/__tests__/task-catalog.test.ts src/app/api/upgrade-config/__tests__/route.test.ts passes 65 tests. npm run lint, npx tsc --noEmit, and prettier --check also pass.

Browser check (npm run dev, headless Chrome, fixture Task with base-signer.json and a malformed security-council.json): both profiles are listed, the picker and summary show base-signer, and POST /api/validate sends userType: "base-signer". The fixture profile then fails schema validation, as expected for a stub file.

…atalog

J-Engine-Session: toshi:c3193bba-dcb1-44ce-98c1-8f0c9a44bf2f
@cb-heimdall

cb-heimdall commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Heimdall Review Status

Requirement Status More Info
Reviews ✅ 1/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
1 if authored by an app that is not allowlisted and lacks verified human attribution 0
Sum 1

@jackchuma

Copy link
Copy Markdown
Collaborator Author

Review round 1

Reviewers: cbhq-openai/gpt-6.1-sol

  • Dropped in triage: [P2] Verify the profile-key migration through the browser — resolved by a coordinator browser check, no code change needed: on a fixture Task, the picker and summary render base-signer, /api/upgrade-config returns {"configOptions":[{"name":"base-signer","displayName":"Base Signer"},{"name":"security-council","displayName":"Security Council"}]} (the second file is malformed JSON), and POST /api/validate sends {"upgradeId":"2026-11-14-browser-check","network":"mainnet","userType":"base-signer"}.
    Synced with main: bff4d20 (already current)
    Validation: not run (no fixes)

🤖 Reply generated with Toshi

@jackchuma
jackchuma marked this pull request as ready for review November 14, 2026 15:12
@leopoldjoy

Copy link
Copy Markdown
Contributor

Validation: all 262 tests, the production build, lint, TypeScript, and formatting passed locally; the change matches CHAIN-6507. I checked the author's browser-check report, but did not independently repeat it or exercise live Forge/hardware-wallet flows.

Reviewed 5a195e1: no remaining approval-blocking findings and relevant code/test CI is passing. @leopoldjoy approves based on this delegated review and will add a +1 when online.

Posted by local automation on behalf of @leopoldjoy; the GitHub approval has not yet been submitted.

@0xth4nh 0xth4nh 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.

Looks good to Thanh's Toshi

@cb-heimdall

Copy link
Copy Markdown
Collaborator

Review Error for xenoliss @ 2026-11-17 16:05:23 UTC
User failed mfa authentication, see go/mfa-help

@cb-heimdall

Copy link
Copy Markdown
Collaborator

Review Error for xenoliss @ 2026-11-17 16:06:43 UTC
User failed mfa authentication, see go/mfa-help

xenoliss
xenoliss previously approved these changes Nov 17, 2026
…ing-task-catalog

J-Engine-Session: toshi:c3193bba-dcb1-44ce-98c1-8f0c9a44bf2f
Comment thread src/lib/task-catalog.ts
throw error;
}
return entries
.filter(entry => entry.isFile() && entry.name.endsWith('.json'))

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.

[P2] Preserve supported in-root profile symlinks (non-blocking)

Dirent.isFile() returns false for symlinks, so a validations/signer.json link to an in-root JSON file silently disappears from the picker. The previous route listed these, and loadProfile explicitly supports them. Preserve contained symlink-to-file entries while excluding directories and outside-root targets, and add listing regression coverage.

Posted by local automation on behalf of @leopoldjoy.

@leopoldjoy

Copy link
Copy Markdown
Contributor

I confirmed symlinked profiles disappear from the picker and accept this as a non-blocking, unfixed residual. Current contract-deployments/main has no checked-in profile symlinks, ordinary profiles still work, and the UI stops rather than using another signing account, so a follow-up can preserve compatibility.

Validation: all 280 tests, build, lint, TypeScript, and formatting pass; the symlink case was reproduced through the real catalog and route. Build passed on retry after an unchanged Next.js cache-advisory reminder (affected APIs are unused here). Prior browser evidence was checked; no independent browser, live Forge, or hardware-wallet run.

Reviewed dc5253d: no remaining approval-blocking findings and relevant code/test CI is passing. @leopoldjoy approves based on this delegated review and will add a +1 when online.

Posted by local automation on behalf of @leopoldjoy; the GitHub approval has not yet been submitted.

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.

5 participants