Repository navigation
fix(loader): recover file-sourced imports after the imported file is moved - #281
Open
perria080925-bot wants to merge 1 commit into
Open
perria080925-bot wants to merge 1 commit into
perria080925-bot wants to merge 1 commit into
Conversation
…moved Fixes flydelabs#112 - When a flow references a node via a file source and the stored relative path no longer resolves (imported file moved to another folder), the loader now searches the project for a file with the same basename and best path-suffix match instead of failing hard. - Direct hits keep the exact previous behavior (zero change for healthy flows). Unresolvable cases still throw the original error. - No new dependencies; search skips node_modules/.git/dist and is depth- and results-capped. - Adds recoverMovedFileSource.spec.ts (5 mocha cases, hermetic fixtures).
This branch has not been deployed
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.
fix(loader): recover file-sourced imports after the imported file is moved
Fixes #112
Root cause
When importing a node from a local file, the editor stores the file's path relative to the importing flow at import time (
{ type: "file", data: relativePath }, seescan-importable-nodes.ts). The loader resolves it asjoin(fullFlowPath, "..", source.data)(findReferencedNodeServer.ts). If the imported file is later moved to another folder, the stored path no longer resolves and the flow fails to load withCannot find node <id> in <path>.What this PR does
recoverMovedFileSource()(loader/src/resolver/server/recoverMovedFileSource.ts): when the stored path is broken, it locates the project root (nearestpackage.json/.git) and searches it for files sharing the stored basename, preferring the candidate whose path suffix best matches the stored relative path.case "file"branch ofcreateServerReferencedNodeFinderonly as a fallback: direct hits keep the exact previous behavior, and fully unresolvable cases still throw the original error. Healthy flows see zero changes.node_modules,.git,dist, etc., and is capped in depth (8) and results (50) to stay fast on large projects.recoverMovedFileSource.spec.tswith 5 hermetic mocha cases (direct hit, recovery after move, node_modules exclusion, no-candidate → null, multiple candidates).Verification
npm testinloader/runs the new spec (mocha, same stack as existing specs).Demo video
▶ demo-flyde-112.webm — 18s
Real terminal run against the branch code: import resolution before/after moving
parts/tonewparts/(stale relative path recovered to the new location), plus the 5-case spec passing./claim #112