Skip to content

refactor(install-deps): find the Task folder through the Task catalog - #238

Open
jackchuma wants to merge 3 commits into
mainfrom
refactor/install-deps-task-catalog
Open

jackchuma wants to merge 3 commits into
mainfrom
refactor/install-deps-task-catalog

Conversation

@jackchuma

@jackchuma jackchuma commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

What changed? Why?

The dependency-install route now gets the Task folder from the Task catalog instead of building paths and running its own id and path checks. Task folder layout and path safety now live only in the catalog. The catalog's taskDirs also throws not-found when the Task folder is missing, and the route maps catalog error kinds through the shared TASK_CATALOG_ERROR_STATUS table from #239.

 POST /api/install-deps
-  regex check on network and upgradeId        -> 400
-  path.join(root, 'active/evm/tasks', id)
-  assertWithinDir                             -> 403 (evm dir) / 500 (task dir)
-  fs.access(taskPath)                         -> 404
+  defaultTaskCatalog().taskDirs(upgradeId, network)
+    TaskCatalogError -> TASK_CATALOG_ERROR_STATUS[kind]  (400 / 403 / 404 / 422)
   make TASK_NETWORK=<network> deps  (cwd: taskDir)

Notes to reviewers

  • Start with src/app/api/install-deps/route.ts, then the six added lines in src/lib/task-catalog.ts.
  • Behavior changes: a Task folder symlinked outside the root now returns 403 (it was 500), and the 400 body now carries the catalog's message (Invalid Task id or network: <id>).
  • Only taskDir must exist for taskDirs. Signature and task-origin folders are still not checked. The private helper behind Task listing is unchanged.
  • Reversibility: git revert undoes it. Blast radius: the install-deps route and future taskDirs callers.

How has it been tested?

Route tests now run the real catalog over a temp fixture root, with only child_process.exec mocked. Each of these was written first and seen failing:

  • catalog taskDirs on a missing Task: did not throw, now throws not-found
  • route with a fixture Task: returned 404 before the route used the catalog, now 200 with make TASK_NETWORK=zeronet deps in the Task folder
  • Task folder symlinked outside the root: returned 500, now 403 and make is not run
  • missing Task folder: returned 500 (under the fixture-backed catalog), now 404 and make is not run
  • invalid id or network: now 400 with the catalog's message and make is not run
npm test -- src/app/api/install-deps src/lib/__tests__/task-catalog.test.ts
Tests: 60 passed, 60 total

npx tsc --noEmit, eslint, and prettier pass on the changed files.

Co-authored-by: Toshi <toshi-noreply@coinbase.com>
J-Engine-Session: toshi:624def25-042b-4225-858e-e20d25f2667f
@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
jackchuma marked this pull request as ready for review November 14, 2026 14:40
@leopoldjoy

Copy link
Copy Markdown
Contributor

Validation: all 267 tests, lint, TypeScript, and formatting passed locally; the change matches CHAIN-6509. The fixture-backed tests check the make invocation; no live contract-deployments dependency installation was run.

Reviewed e64f906: 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.

Comment thread src/app/api/install-deps/route.ts Outdated
return NextResponse.json({ success: true }, { status: 200 });
} catch (error) {
if (error instanceof TaskCatalogError) {
const statuses: Partial<Record<TaskCatalogError['kind'], number>> = {

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.

This map duplicates TASK_CATALOG_ERROR_STATUS, which #239 adds to task-catalog.ts for this route to reuse. Both PRs branch from main and merge without conflict, so once both land the catalog's kind-to-status mapping lives in two places and can drift. Use TASK_CATALOG_ERROR_STATUS here once #239 lands (the "unmapped catalog kind" test then expects 422 for invalid-profile).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 8de64cb. I merged main, which now has #239, and the route maps every TaskCatalogError through TASK_CATALOG_ERROR_STATUS[error.kind]. The local map is gone. The invalid-profile case moved out of the 500 table into its own test, which expects 422.

🤖 Reply generated with Toshi

@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

…-task-catalog

J-Engine-Session: toshi:624def25-042b-4225-858e-e20d25f2667f
J-Engine-Session: toshi:624def25-042b-4225-858e-e20d25f2667f
@leopoldjoy

Copy link
Copy Markdown
Contributor

The author's switch to the canonical status table fixes the duplicated mapping, including the 422 regression case.

Validation: all 284 tests, production build, lint, TypeScript, and formatting pass. The build passed on retry after an existing Next.js cache-advisory reminder; the affected cache APIs are unused in application source. The unchanged dependency still needs a separate upgrade. No live dependency installation was run.

Reviewed 8de64cb: 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

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