From 3d321762ac6b5fd1769bd0547314e56291fc8a4d Mon Sep 17 00:00:00 2001 From: Dan Smolsky <78942835+Tarquinen@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:01:23 -0500 Subject: [PATCH] fix(core): ignore a corrupt cached project id (#62576) --- packages/core/src/project.ts | 2 +- packages/core/test/project.test.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/src/project.ts b/packages/core/src/project.ts index 63a523b5fb0..5a6356926e5 100644 --- a/packages/core/src/project.ts +++ b/packages/core/src/project.ts @@ -309,7 +309,7 @@ const layer = Layer.effect( const cached = Effect.fnUntraced(function* (dir: string) { return yield* fs.readFileString(path.join(dir, "opencode")).pipe( Effect.map((value) => value.trim()), - Effect.map((value) => (value ? ID.make(value) : undefined)), + Effect.map((value) => (value && !/[\u0000-\u001f\u007f]/.test(value) ? ID.make(value) : undefined)), Effect.orElseSucceed(() => undefined), ) }) diff --git a/packages/core/test/project.test.ts b/packages/core/test/project.test.ts index c2dd1b98f90..7825e05e448 100644 --- a/packages/core/test/project.test.ts +++ b/packages/core/test/project.test.ts @@ -478,10 +478,11 @@ describe("Project.resolve", () => { }), ) - it.live("falls back to root commit when origin is missing", () => + it.live("falls back to root commit when origin is missing and the cached id is corrupt", () => Effect.gen(function* () { const tmp = yield* tmpdirScoped() yield* Effect.promise(() => initRepo(tmp.path, { commit: true })) + yield* Effect.promise(() => Bun.write(path.join(tmp.path, ".git", "opencode"), "\u0000".repeat(40))) const project = yield* Project.Service const result = yield* project.resolve(abs(tmp.path))