Skip to content

bug: tool.registry test fails on CI — custom tool import crashes registry when dependencies are missing #12269

@mguttmann

Description

@mguttmann

Description

The test tool.registry > loads tools with external dependencies without crashing introduced in #12227 (556adad67) fails deterministically on CI:

error: Cannot find package 'cowsay' from '/tmp/opencode-test-xxx/.opencode/tools/cowsay.ts'
(fail) tool.registry > loads tools with external dependencies without crashing [269.71ms]

This blocks all PRs targeting dev — the test (linux) check fails with 881 pass / 1 fail.

Root cause

Two issues:

  1. No error handling in ToolRegistry.state()await import(match) on line 44 of registry.ts throws when a custom tool has unresolvable dependencies, crashing the entire registry initialization instead of gracefully skipping the broken tool.

  2. Test expects successful load without installing deps — the test creates a package.json with cowsay dependency but the dependency is never installed in the temp directory. Config.waitForDependencies() doesn't trigger the install in the test context. The test then asserts expect(ids).toContain("cowsay") which fails because the import throws.

Impact

Every PR targeting dev fails the test (linux) CI check. This started after #12227 was merged.

Suggested fix

  1. Wrap the import(match) in registry.ts with try/catch — log a warning and skip tools that fail to import
  2. Update the test expectation to not.toContain("cowsay") since the test name says "without crashing" (testing resilience, not successful loading)

PR with fix: incoming

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions