fix(app): handle empty path in file list to avoid leading slash#233
Closed
fix(app): handle empty path in file list to avoid leading slash#233
Conversation
Collaborator
Author
|
Closing this PR as the changes were exposing a pre-existing upstream bug. The root cause needs to be investigated separately - it appears to be related to running |
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.
Summary
These changes ensure proper file listing at the project root level.
Greptile Summary
Fixed file listing at project root by handling empty path correctly. The changes ensure that when listing files in the root directory, an empty string is passed to the API instead of a leading slash (
"/"), and thefetchfunction always callslistfor the parent directory, even when the parent is the root (empty string).Key changes:
listfunction to conditionally add trailing slash: uses empty string for root, adds"/"suffix for non-empty pathsfetchfunction that prevented listing root directory when parent was empty"/"from being sent to the file listing APIThe fix aligns with the backend
File.listimplementation which expects an optional directory parameter that can be empty for root listings.Confidence Score: 5/5
Important Files Changed
Sequence Diagram
sequenceDiagram participant User participant FileContext as File Context participant SDK as SDK Client participant Server as File Server Note over User,Server: Scenario: Fetching a file at root level User->>FileContext: fetch(path) FileContext->>FileContext: relativePath = relative(path) FileContext->>FileContext: parent = relativePath.split("/").slice(0, -1).join("/") Note over FileContext: parent is empty string "" for root files FileContext->>FileContext: list(parent) alt Before Fix: parent was "" FileContext->>FileContext: Check if (parent) - FALSE Note over FileContext: list() not called, directory not loaded! else After Fix: parent is "" FileContext->>SDK: file.list({ path: "" }) Note over SDK: listPath = "" ? "" + "/" : "" = "" SDK->>Server: GET /file?path="" Server->>SDK: Returns root directory contents SDK->>FileContext: Update store with file nodes end Note over User,Server: Scenario: Listing root directory User->>FileContext: list("") alt Before Fix FileContext->>SDK: file.list({ path: "" + "/" }) Note over SDK: Results in path: "/" (leading slash issue) SDK->>Server: GET /file?path="/" Note over Server: May cause incorrect path resolution else After Fix FileContext->>FileContext: listPath = "" ? "" : "" + "/" Note over FileContext: listPath = "" FileContext->>SDK: file.list({ path: "" }) SDK->>Server: GET /file?path="" Server->>FileContext: Returns correct root listing end