fix(core): ignore a corrupt cached project id (#62576)

This commit is contained in:
Dan Smolsky
2026-11-16 20:01:23 -05:00
committed by GitHub
Unverified
parent 0a72d0dc15
commit 3d321762ac
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -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),
)
})
+2 -1
View File
@@ -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))