A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/grafana/mcp-grafana/commit/c03ca3c387b2cd9b3d8d2fbd56d2a9e6b7b603fb below:

Add better error behavior for sift (#161) · grafana/mcp-grafana@c03ca3c · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+16

-4

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+16

-4

lines changed Original file line number Diff line number Diff line change

@@ -440,18 +440,30 @@ func (c *siftClient) makeRequest(ctx context.Context, method, path string, body

440 440 441 441

response, err := c.client.Do(req)

442 442

if err != nil {

443 -

return nil, err

443 +

return nil, fmt.Errorf("executing request: %w", err)

444 444

}

445 - 446 -

reader := io.LimitReader(response.Body, 1024*1024*48)

447 445

defer response.Body.Close()

448 446 447 +

// Check for non-200 status code (matching Loki client's logic)

448 +

if response.StatusCode != http.StatusOK {

449 +

bodyBytes, _ := io.ReadAll(response.Body) // Read full body on error

450 +

return nil, fmt.Errorf("API request returned status code %d: %s", response.StatusCode, string(bodyBytes))

451 +

}

452 + 453 +

// Read the response body with a limit to prevent memory issues

454 +

reader := io.LimitReader(response.Body, 1024*1024*48) // 48MB limit

449 455

buf, err := io.ReadAll(reader)

450 456

if err != nil {

451 457

return nil, fmt.Errorf("failed to read response body: %w", err)

452 458

}

453 459 454 -

return buf, nil

460 +

// Check if the response is empty (matching Loki client's logic)

461 +

if len(buf) == 0 {

462 +

return nil, fmt.Errorf("empty response from API")

463 +

}

464 + 465 +

// Trim any whitespace that might cause JSON parsing issues (matching Loki client's logic)

466 +

return bytes.TrimSpace(buf), nil

455 467

}

456 468 457 469

// getSiftInvestigation is a helper method to get the current status of an investigation

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4