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:
@@ -76,7 +76,6 @@ func isNetworkError(err error, msg string) bool {
|
||||
}
|
||||
|
||||
networkHints := []string{
|
||||
"dial",
|
||||
"connection refused",
|
||||
"eof",
|
||||
"broken pipe",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user