Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return response with errorsource instead of nil #1069

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion internal/automanagement/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt"
"github.com/grafana/grafana-plugin-sdk-go/experimental/errorsource"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand All @@ -27,7 +28,13 @@ func NewManager(instanceManager instancemgmt.InstanceManager) *Manager {
func (m *Manager) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
h, err := m.Get(ctx, req.PluginContext)
if err != nil {
return nil, err
if len(req.Queries) == 0 {
// shouldn't be possible, but just in case
return nil, err
}
resp := backend.NewQueryDataResponse()
errorsource.AddErrorToResponse(req.Queries[0].RefID, resp, err)
andresmgot marked this conversation as resolved.
Show resolved Hide resolved
return resp, err
}
if ds, ok := h.(backend.QueryDataHandler); ok {
return ds.QueryData(ctx, req)
Expand Down