mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-24 16:41:30 +02:00
[misc] Teach the discovery e2e the Bedrock listing envelope
The live run proved the routing change: Bedrock answered
GET /inference-profiles with 200 and real inference profiles from the
control plane. The test then failed anyway, because its own id extractor
only knew {"data":[{"id":…}]} and reported the response as 'not a
listing' — the one shape the proxy had just been taught to filter.
Read both envelopes here, for the same reason the filter reads both: the
two have to stay in step, or this test contradicts the code it covers.
This commit is contained in:
@@ -367,24 +367,39 @@ func isProxyError(body string) bool {
|
||||
}
|
||||
|
||||
// listingIDs pulls the model ids out of a listing response. ok is false when
|
||||
// the body is not the {"data":[{"id":…}]} shape the filter recognises.
|
||||
// the body is neither envelope the proxy's filter recognises — the two must
|
||||
// stay in step, or this test reports "not a listing" for a response the proxy
|
||||
// filtered perfectly well.
|
||||
func listingIDs(body string) ([]string, bool) {
|
||||
var doc struct {
|
||||
// OpenAI's shape, which Anthropic adopted.
|
||||
Data []struct {
|
||||
ID string `json:"id"`
|
||||
} `json:"data"`
|
||||
// Bedrock returns inference-profile summaries under a key of its own,
|
||||
// with the id under a field of its own.
|
||||
Summaries []struct {
|
||||
ID string `json:"inferenceProfileId"`
|
||||
} `json:"inferenceProfileSummaries"`
|
||||
}
|
||||
if err := json.Unmarshal([]byte(body), &doc); err != nil {
|
||||
return nil, false
|
||||
}
|
||||
if doc.Data == nil {
|
||||
return nil, false
|
||||
switch {
|
||||
case doc.Data != nil:
|
||||
ids := make([]string, 0, len(doc.Data))
|
||||
for _, entry := range doc.Data {
|
||||
ids = append(ids, entry.ID)
|
||||
}
|
||||
return ids, true
|
||||
case doc.Summaries != nil:
|
||||
ids := make([]string, 0, len(doc.Summaries))
|
||||
for _, entry := range doc.Summaries {
|
||||
ids = append(ids, entry.ID)
|
||||
}
|
||||
return ids, true
|
||||
}
|
||||
ids := make([]string, 0, len(doc.Data))
|
||||
for _, entry := range doc.Data {
|
||||
ids = append(ids, entry.ID)
|
||||
}
|
||||
return ids, true
|
||||
return nil, false
|
||||
}
|
||||
|
||||
func caseNames(cases []liveDiscoveryCase) []string {
|
||||
|
||||
Reference in New Issue
Block a user