Skip to content

Commit cb415c3

Browse files
authored
appnet: fix QueryPaths error handling (#186)
An empty non-error response could lead to no path being set by SetDefaultPath. Explicitly return an error if the no path was found in QueryPaths.
1 parent 0aa8bec commit cb415c3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/appnet/path_selection.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package appnet
1717
import (
1818
"bufio"
1919
"context"
20+
"errors"
2021
"fmt"
2122
"math"
2223
"os"
@@ -110,9 +111,12 @@ func QueryPaths(ia addr.IA) ([]snet.Path, error) {
110111
return nil, nil
111112
} else {
112113
paths, err := DefNetwork().PathQuerier.Query(context.Background(), ia)
113-
if err != nil || len(paths) == 0 {
114+
if err != nil {
114115
return nil, err
115116
}
117+
if len(paths) == 0 {
118+
return nil, errors.New("no path available")
119+
}
116120
paths = filterDuplicates(paths)
117121
return paths, nil
118122
}

0 commit comments

Comments
 (0)