mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-13 23:33:22 +00:00
fix(core): reject inherited workspace providers (#42227)
This commit is contained in:
parent
c253d4d311
commit
56973e0ca4
2 changed files with 13 additions and 1 deletions
|
|
@ -55,7 +55,7 @@ export class RegistryService extends Context.Service<RegistryService, Registry>(
|
|||
|
||||
export const registry = (drivers: Readonly<Record<string, Interface>>): Registry => ({
|
||||
get: (provider) => {
|
||||
const driver = drivers[provider]
|
||||
const driver = Object.hasOwn(drivers, provider) ? drivers[provider] : undefined
|
||||
return driver ? Effect.succeed(driver) : Effect.fail(new ProviderNotFound({ provider }))
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -48,6 +48,18 @@ beforeEach(() => {
|
|||
failConnect = false
|
||||
})
|
||||
|
||||
it.effect("rejects unregistered workspace providers", () =>
|
||||
Effect.gen(function* () {
|
||||
const registry = WorkspaceDriver.registry({ fake: driver })
|
||||
|
||||
for (const provider of ["missing", "constructor", "toString", "__proto__"]) {
|
||||
expect(yield* registry.get(provider).pipe(Effect.flip)).toEqual(
|
||||
new WorkspaceDriver.ProviderNotFound({ provider }),
|
||||
)
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("persists the workspace lifecycle and reconnects after idle suspension", () =>
|
||||
Effect.gen(function* () {
|
||||
const workspace = yield* Workspace.Service
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue