p3: tavily parse errors degrade; retry DNS on search
A 200 with a bad Tavily body is tavily: error, not an empty success that would cache for the hour. Upstream clients stay in the source list if DNS is down at boot and retry the pin on Search; /healthz lists them as unresolved until a pin lands.
This commit is contained in:
@@ -95,3 +95,21 @@ func TestBraveMapsSources(t *testing.T) {
|
||||
t.Fatal("grounding used as snippet")
|
||||
}
|
||||
}
|
||||
|
||||
func TestTavilyBadJSONIsError(t *testing.T) {
|
||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = w.Write([]byte(`not-json`))
|
||||
}))
|
||||
defer ts.Close()
|
||||
c, err := dial.New(ts.URL, dial.Options{Loopback: true, Timeout: time.Second})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
out := (&Tavily{Client: c, Key: "k"}).Search(context.Background(), "q", 5)
|
||||
if out.Warn != "tavily: error" {
|
||||
t.Fatalf("warn %q", out.Warn)
|
||||
}
|
||||
if len(out.Hits) != 0 || out.Credits != 0 {
|
||||
t.Fatalf("%+v", out)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user