Repository navigation
fix(project): do not read a failed enumeration as an empty project store - #783
Merged
Ishaan Gangwani (ishaan1124) merged 1 commit intoSep 29, 2026
Conversation
ANIRUDDHA ADAK (aniruddhaadak80)
requested review from
Aayam Bansal (aayambansal) and
Ishaan Gangwani (ishaan1124)
as code owners
September 28, 2026 08:45
|
ANIRUDDHA ADAK (@aniruddhaadak80) is attempting to deploy a commit to the InkVell Team on Vercel. A member of the Team first needs to authorize it. |
Ishaan Gangwani (ishaan1124)
force-pushed
the
fix/project-list-error-identity
branch
from
September 29, 2026 01:24
96a0dfa to
fbaac69
Compare
Storage.list rethrows on a permission error precisely so a caller cannot mistake an unreadable store for an empty one, and records() swallowed it. Opening a folder whose project record already existed then minted a second prj_ id for the same worktree and adopted no legacy sessions, stranding the folder's history. Let the error reach the caller.
Ishaan Gangwani (ishaan1124)
force-pushed
the
fix/project-list-error-identity
branch
from
September 29, 2026 01:31
fbaac69 to
5a61327
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do, and why?
Project.fromDirectorydecides whether a worktree already has a project record.The lookup swallowed any failure and treated the result as authoritative:
Storage.listwas deliberately hardened to not do this — it logs and rethrows,and
test/storage/list-errors.test.tspins that with the name "a permissionerror surfaces instead of masquerading as an empty prefix". This one call site
took it back.
With
found = [],fromDirectorytreats the folder as new:and then writes a second project record for a worktree that already has one,
while
adoptLegacy(id, worktree, found)is handed an empty list and adoptsnothing. The pre-existing
project/<oldId>.jsonand everysession/<oldId>/*.jsonare left attached to an id nothing uses any more. Theuser opens their folder and their conversation history is simply not there — and
it only self-heals if they open the same folder in a later process, by which
point sessions written under the orphan id are stranded too.
The fix is to let the hardened error reach the caller. The surrounding
FileLeasealready covers the write, and a retriedfromDirectoryis strictlybetter than a forked identity:
Linked issue
Self-identified. Happy to file a report if you would rather track it; my issue
budget this turn went to the two
apply_patchdefects and thelocalStoragecopies.
How did you verify it?
One case in
backend/cli/test/project/project-registration.test.ts:a failure to enumerate projects is not read as an empty store. It makes the["project"]read fail, then assertsProject.fromDirectoryrejects, andthat no second project record was written.
On unmodified
3e94875cit resolves instead:Being straight about the test: it stubs the failing read rather than provoking a
real one. A real failure needs a POSIX
chmodon the store directory, which iswhy the repo's own
list-errors.test.tscase isskipIf(process.platform === "win32" || process.getuid?.() === 0)and does not run on this machine. Stubbingthe read is the only portable way to reach this branch here. The stub is
scoped to the
["project"]prefix and restored in afinally, andStorage.list's own rethrow is covered by the existing test.Commands run:
bun test --timeout 60000 ./test/project/project-registration.test.ts -t "not read as an empty store"→ 1 pass
bun test --timeout 180000 ./test/project/project-registration.test.ts→ 8 pass, 1 fail — the failure is the
(unnamed)teardown fromtest/preload.ts, which cannotrmits temp data dir on Windows (EBUSY) andis present on unmodified
mainin every run I have done in this repobun run --cwd backend/cli typecheck→ exit 0The rest of that file matters more than the new case: registration boundaries,
the managed-parent relationship and the "no second record" invariant are all
covered there, and none moved.
One consequence worth naming
fromDirectorycan now fail where it previously succeeded, for a user whoseproject store is transiently unreadable. That is the intended trade — a visible
error the user can retry, instead of a silent fork that loses history — but it is
a behaviour change and I would rather you hear it from me than from a bug report.
Checklist
bun run checkis green (format, typecheck, backend + frontend/ui + SDK tests) — blocked on this Windows checkout by the CRLF and symlink artifacts in my other pull requests; backend typecheck is clean and project registration adds no new failurebun run --cwd frontend/workspace buildsucceeds if I touchedfrontend/workspaceorfrontend/ui— not touched./tooling/repo/generate.tswas run and thetooling/sdkoutput committed if I changedbackend/cli/src/server— not touchedfrontend/docs/src/content/openscience/is updated if behavior changed — no doc change needed: project identity is internalpackage.jsonversions and tags are written by the release workflow)installandfrontend/landing/public/installare still byte-identical if I touched either — not touched