-
Notifications
You must be signed in to change notification settings - Fork 2
fix(cli): require explicit source for unknown-server fallback #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ var ( | |
| } | ||
| resolveSourceFn = bootstrap.Resolve | ||
| checkPrereqsFn = bootstrap.CheckPrerequisites | ||
| statSourceFn = os.Stat | ||
| ) | ||
|
|
||
| // Run is the main CLI entry point. Returns an exit code. | ||
|
|
@@ -756,6 +757,9 @@ func sendServerRequestWithEphemeralFallback(client daemonRequester, req *ipc.Req | |
| if effectiveReq.Ephemeral != nil || !isUnknownServerResponse(resp, effectiveReq.Server) { | ||
| return resp, nil | ||
| } | ||
| if !looksLikeExplicitEphemeralSource(effectiveReq.Server) { | ||
| return resp, nil | ||
| } | ||
|
|
||
| ephemeral, resolveResp := resolveEphemeralSource(effectiveReq.Server) | ||
| if resolveResp != nil { | ||
|
|
@@ -856,7 +860,12 @@ func looksLikeExplicitEphemeralSource(source string) bool { | |
| if strings.Contains(lower, "?config=") { | ||
| return true | ||
| } | ||
| return false | ||
|
|
||
| info, err := statSourceFn(filepath.Clean(source)) | ||
| if err != nil { | ||
| return false | ||
| } | ||
| return info.Mode().IsRegular() | ||
|
Comment on lines
+864
to
+868
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| func isUnknownServerResponse(resp *ipc.Response, server string) bool { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new guard skips fallback unless
looksLikeExplicitEphemeralSourceis true, but that helper does not recognize valid relative file paths without/or a.json/.tomlsuffix (for examplemcpx manifest ping {}when./manifestis a JSON/TOML manifest). Before this commit those sources resolved viabootstrap.Resolve(which reads arbitrary file paths), so this change regresses legitimate ephemeral-source invocations intounknown servererrors.Useful? React with 👍 / 👎.