Repository navigation
fix(sync): an import of a folder further up links its index file when it appears - #2669
Merged
Merged
Conversation
… it appears An import that names a folder only through where it is written (`.`, `..`, `../..`) is parked under no key, so sync tries each where it is written when files are added (#2528). That lookup listed `.`, `./`, `..` and `../` only, so `import { Excalidraw } from "../.."` in excalidraw's tests, or any import of a folder two or more levels up, stayed unlinked after its folder's `index` file was added or restored, though a fresh index links it. It now lists the folder up to twelve levels above, with or without the trailing slash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #2666, from its validation.
Problem
An import that names a folder only through where it is written (
.,..,../..) parks under no key, so sync tries each one where it is written whenever files are added (#2528'sgetFailedFolderImports). That lookup listed.,./,..and../only. An import of a folder two or more levels up stayed unlinked after the folder'sindexfile was added or restored, though a fresh index links it.'../../'even parks under a stray/tail.Seen in #2666's hold-out scenario on both arms: excalidraw's
import { Excalidraw } from "../.."inFontPicker.test.tsx,siderbar.test.helpers.tsxandstats.test.tsx(topackages/excalidraw/index.tsx), and two in bitwarden.Fix
getFailedFolderImportsnow lists the folder up to twelve levels above, with and without the trailing slash: 26 names in oneINlist.I also checked Python's
from ... import x, whose module ref is...: a fresh index doesn't link it to the package's__init__.pyeither, so there's no sync gap there and it isn't listed.Validation
Arms:
main= 437b5c3,fix= this branch, with the same native kernel. Kit:D:\cgwork\cgceil.Regression test: a TypeScript case in
sync-import-retry.test.ts's per-language table.src/a/b/c/m.tsimports'../..','../../'and'../../..'. A sync then addssrc/a/index.tsandsrc/index.ts, and the result is compared with a from-scratch rebuild. It fails on main, where only the bindings link, and passes here.Fresh indexes, byte-identical controls: 9/9 identical (folo, vben, milo-ui, ghostfolio, infrahub, excalidraw, bitwarden, gin, django-realworld). The change only acts in sync.
Late scenario (every 7th source file held out, then synced; each arm compared with its own fresh dump):
import … from "../.."'../..'imports and the 12 binding/reference edges that follow themvben's sync still fails with #2565's
FOREIGN KEY constraint failedon both arms (#2574 is open for it).Cost/plan: the lookup stays on
idx_unresolved_failed_import_name(SEARCH … USING INDEX idx_unresolved_failed_import_name (reference_kind=? AND reference_name=?)). On bitwarden's index it takes 0.8 ms for 26 names and finds 2 rows.Full suite, with main's #2668 merged in and the native kernel built from main's source (
CODEGRAPH_KERNEL_EXPECT=1,--maxWorkers=4): 612 files passed, 6 skipped; 7,477 tests passed, 0 failed, 80 skipped.🤖 Generated with Claude Code