Skip to content

fix notfound error in settings#3212

Open
sawka wants to merge 1 commit intomainfrom
sawka/notfound-settings-bug
Open

fix notfound error in settings#3212
sawka wants to merge 1 commit intomainfrom
sawka/notfound-settings-bug

Conversation

@sawka
Copy link
Copy Markdown
Member

@sawka sawka commented Apr 10, 2026

No description provided.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 10, 2026

Walkthrough

The RemoteFileStreamCommand function in pkg/wshrpc/wshremote/wshremote_file.go was modified to handle missing file paths differently. When a path does not exist (os.IsNotExist(err)), the function now treats this as a successful response rather than an error. It closes the stream writer and returns a wshrpc.FileInfo response with NotFound: true, including the path with home-directory replacement and the directory computed from the request data. All other stat errors continue to follow the original error handling behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess relevance to the changeset. Add a description explaining the bug being fixed and why the specific change to handle missing paths as 'not found' responses is necessary.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title references a specific bug fix (notfound error in settings) and aligns with the changeset which handles missing paths in file operations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sawka/notfound-settings-bug

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/wshrpc/wshremote/wshremote_file.go`:
- Around line 568-574: The os.IsNotExist(err) branch in wshremote_file.go
currently returns a FileInfo with NotFound:true and a nil error, which breaks
the existing RPC contract because callers in pkg/remote/fileshare/wshfs/wshfs.go
only check err/IsDir and won't stop reading; change this branch to surface a
non-nil error (e.g., return an os.ErrNotExist or wrap the original err) instead
of returning nil so callers see the file-missing error, ensuring
wshrpc.FileInfo.NotFound is not relied on by existing code; alternatively (if
you prefer caller-side change) update the callers in wshfs.go to explicitly
check FileInfo.NotFound before proceeding, but prefer returning the error from
the os.IsNotExist(err) branch to preserve the original contract.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 136bbaa0-972e-402c-87cf-83c0d80b2714

📥 Commits

Reviewing files that changed from the base of the PR and between 9f41b57 and 2235d3d.

📒 Files selected for processing (1)
  • pkg/wshrpc/wshremote/wshremote_file.go

Comment on lines +568 to +574
if os.IsNotExist(err) {
writer.Close()
return &wshrpc.FileInfo{
Path: wavebase.ReplaceHomeDir(data.Path),
Dir: computeDirPart(data.Path),
NotFound: true,
}, nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Contract change can silently mask missing files as successful reads.

At Line 568, returning nil error for missing paths changes the stream RPC contract. In pkg/remote/fileshare/wshfs/wshfs.go (Line 70-92), the caller only checks err/IsDir, not FileInfo.NotFound, so this path can continue and treat a non-existent file as a successful empty read.

Please either keep not-found as an error for this RPC, or update stream callers to gate on fileInfo.NotFound before reading.

Suggested caller-side guard (outside this file)
--- a/pkg/remote/fileshare/wshfs/wshfs.go
+++ b/pkg/remote/fileshare/wshfs/wshfs.go
@@
 fileInfo, err := wshclient.RemoteFileStreamCommand(RpcClient, remoteData, &wshrpc.RpcOpts{Route: writerRouteId})
 if err != nil {
 	return nil, fmt.Errorf("starting remote file stream: %w", err)
 }
+if fileInfo != nil && fileInfo.NotFound {
+	return &wshrpc.FileData{Info: fileInfo}, nil
+}
 var rawData []byte
 if fileInfo != nil && !fileInfo.IsDir {
 	rawData, err = io.ReadAll(reader)
 	if err != nil {
 		return nil, fmt.Errorf("reading file stream: %w", err)
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/wshrpc/wshremote/wshremote_file.go` around lines 568 - 574, The
os.IsNotExist(err) branch in wshremote_file.go currently returns a FileInfo with
NotFound:true and a nil error, which breaks the existing RPC contract because
callers in pkg/remote/fileshare/wshfs/wshfs.go only check err/IsDir and won't
stop reading; change this branch to surface a non-nil error (e.g., return an
os.ErrNotExist or wrap the original err) instead of returning nil so callers see
the file-missing error, ensuring wshrpc.FileInfo.NotFound is not relied on by
existing code; alternatively (if you prefer caller-side change) update the
callers in wshfs.go to explicitly check FileInfo.NotFound before proceeding, but
prefer returning the error from the os.IsNotExist(err) branch to preserve the
original contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant