Azure: Fix possible nil pointer dereference (#111051)

* Fix possible nil pointer dereference

* Update pkg/tsdb/azuremonitor/loganalytics/azure-log-analytics-datasource.go

Co-authored-by: Adam Yeats <16296989+adamyeats@users.noreply.github.com>

---------

Co-authored-by: Adam Yeats <16296989+adamyeats@users.noreply.github.com>
This commit is contained in:
Andreas Christou 2025-09-19 13:53:51 +02:00 committed by GitHub
parent 75286f11f0
commit 00d47ceb29
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 1 deletions

View File

@ -128,7 +128,11 @@ func (e *AzureLogAnalyticsDatasource) ResourceRequest(rw http.ResponseWriter, re
req.URL.RawQuery = queryParams.Encode()
resp, err := cli.Do(req)
if err != nil {
return nil, writeErrorResponse(rw, resp.StatusCode, fmt.Sprintf("failed to fetch metadata: %s", err))
statusCode := http.StatusInternalServerError
if resp != nil {
statusCode = resp.StatusCode
}
return nil, writeErrorResponse(rw, statusCode, fmt.Sprintf("failed to fetch metadata: %v", err))
}
defer func() {