Before submitting
Area
apps/server
Steps to reproduce
- Have a project for a GitHub repository, for example
pingdotgg/t3code, in one environment.
- In another environment, add a project with clone from GitHub for the same repository, into a folder that is not inside another Git repository.
- Wait for the clone to finish, then look at the sidebar on a client connected to both environments.
Expected behavior
When the clone finishes, the new project gets the repository's identity and groups with the other pingdotgg/t3code project.
Actual behavior
The project keeps repositoryIdentity: null after the clone finishes. Clients group it by its folder path, so it shows as its own sidebar entry. It only joins the group after the server's cached null expires and something asks for that project's metadata again.
Timeline from one occurrence:
- 22:34:32: project created; its empty folder appears in the same second
- 22:34:50:
.git/config written by the clone
- 22:34:52: the
project-clone-done update runs and still sends repositoryIdentity: null
Impact
Minor bug or occasional failure
Version or commit
Source inspected: main @ 4d73e1d
Environment
Server-side; does not depend on OS or client.
Code investigation
At the inspected commit, repository identity is cached in two layers:
RepositoryIdentityResolver keeps a null result for 1 minute; resolve(cwd, { refresh: true }) bypasses it.
ProjectEnrichmentService has its own repositoryIdentityCache keyed by workspace root. A resolved null counts as a success and is kept for 1 minute. Clients read identity from this layer.
The clone flow:
createProject calls ProjectService.create, which invalidates enrichment. The folder is still empty, so the next read resolves null and layer 2 caches it.
onCloned calls repositoryIdentityResolver.resolve(root, { refresh: true }), which refreshes only layer 1, then projectService.update({ projectId }). ProjectService.update invalidates enrichment only when the workspace root changes, so the update reads the stale null from layer 2 and sends it to clients.
- With no identity,
deriveLogicalProjectKey falls back to the per-environment path key, so the project gets its own group.
#17047 adds ProjectEnrichmentService.refresh, which refreshes both layers and publishes the result, and calls it from onCloned. That covers this case too, but its test only covers the parent-repository case, not a project created with no identity that gains one when the clone lands.
Other refresh: true call sites I checked:
Workaround
None needed in most cases: it fixes itself once the cached null expires (1 minute after it was resolved) and the project's metadata is read again, for example on a client reconnect.