fix(stream): avoid dial substring false-positive in ClassifyError

Remove "dial" from networkHints to stop "dialogue" misclassification;
extend workspace/resumable and EmitErrorInfo test coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WeiCHEN
2026-09-09 16:09:39 +08:00
co-authored by Cursor
parent f385515ad3
commit bfa68892ac
3 changed files with 44 additions and 1 deletions
-1
View File
@@ -76,7 +76,6 @@ func isNetworkError(err error, msg string) bool {
}
networkHints := []string{
"dial",
"connection refused",
"eof",
"broken pipe",
+17
View File
@@ -45,14 +45,31 @@ func TestClassifyError_WorkspaceHintIsResumable(t *testing.T) {
t.Fatalf("class=%s", info.Class)
}
hasContinue := false
hasRestart := false
for _, a := range info.Actions {
if a == "continue" {
hasContinue = true
}
if a == "restart" {
hasRestart = true
}
}
if !hasContinue {
t.Fatalf("expected continue, got %v", info.Actions)
}
if !hasRestart {
t.Fatalf("expected restart, got %v", info.Actions)
}
}
func TestClassifyError_DialogueNotNetwork(t *testing.T) {
info := ClassifyError(errors.New("dialogue generation failed"), "dialogue_generating", "req_5", "sess_1", "")
if info.Class == ErrorClassTransient {
t.Fatalf("dialogue substring must not classify as transient/network, class=%s code=%s", info.Class, info.Code)
}
if info.Class != ErrorClassFatal {
t.Fatalf("class=%s", info.Class)
}
}
func TestClassifyError_NetworkIsTransient(t *testing.T) {
+27
View File
@@ -51,6 +51,33 @@ func TestStreamer_BasicEvents(t *testing.T) {
}
}
func TestStreamer_EmitError_PopulatesErrorInfo(t *testing.T) {
rawErr := errors.New("invalid project config")
var received StreamEvent
streamer := NewStreamer(true, func(ev StreamEvent) {
received = ev
})
streamer.EmitError(rawErr)
if received.Type != EventError {
t.Fatalf("type=%s", received.Type)
}
if received.ErrorInfo == nil {
t.Fatal("ErrorInfo is nil")
}
if received.Error != received.ErrorInfo.UserMessage {
t.Fatalf("Error=%q UserMessage=%q", received.Error, received.ErrorInfo.UserMessage)
}
if received.ErrorInfo.Upstream != rawErr.Error() {
t.Fatalf("Upstream=%q want %q", received.ErrorInfo.Upstream, rawErr.Error())
}
if received.ErrorInfo.Class == "" {
t.Fatal("Class is empty")
}
}
func TestStreamer_FilterDetails(t *testing.T) {
var received []StreamEvent