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

[Bug]: failing to get alerts list using Go SDK #87

Closed
wasilak opened this issue Nov 13, 2024 · 4 comments
Closed

[Bug]: failing to get alerts list using Go SDK #87

wasilak opened this issue Nov 13, 2024 · 4 comments
Assignees

Comments

@wasilak
Copy link

wasilak commented Nov 13, 2024

Expected Result

I am expecting to be able to list alerts :)

Actual Result

Hey guys! please advise :) I'm getting a proto related error when using func (a cxsdk.AlertsClient) List(ctx context.Context, req *v3.ListAlertDefsRequest) (*v3.ListAlertDefsResponse, error), see below.

rpc error: code = Internal desc = grpc: failed to unmarshal the received message: proto: cannot parse invalid wire-format data

This is the code I'm using:

package coralogix

import (
	"log/slog"

	cxsdk "github.com/coralogix/coralogix-management-sdk/go"
)

type ConnectionAlerts struct {
	AlertsClient *cxsdk.AlertsClient
}

func (c *Coralogix) setupConnectionAlerts() ConnectionAlerts {
	authContext := cxsdk.NewAuthContext(c.connectionParams.TeamLevelAPIKey, c.connectionParams.UserLevelAPIKey)
	creator := cxsdk.NewCallPropertiesCreator(c.connectionParams.Region, authContext)

	return ConnectionAlerts{
		AlertsClient: cxsdk.NewAlertsClient(creator),
	}
}

func (c *Coralogix) GetAlertsMetrics() error {
	c.connectionAlerts = c.setupConnectionAlerts()

	err := c.generatAlertsListMetric()
	if err != nil {
		return err
	}

	return nil
}

func (c *Coralogix) generatAlertsListMetric() error {
	alertDefReq := &cxsdk.ListAlertDefsRequest{}
	alerts, err := c.connectionAlerts.AlertsClient.List(c.CTX, alertDefReq) // <------  here the error happens 
	if err != nil {
		return err
	}

	for _, alert := range alerts.AlertDefs {
		slog.DebugContext(c.CTX, "Alert", "name", alert.GetId(), "description", alert.AlertDefProperties.GetDescription())
	}

	return nil
}

Relevant log output

rpc error: code = Internal desc = grpc: failed to unmarshal the received message: proto: cannot parse invalid wire-format data
@celaus
Copy link
Contributor

celaus commented Dec 2, 2024

Hi - what version of the SDK are you using?

@celaus celaus self-assigned this Dec 2, 2024
@wasilak
Copy link
Author

wasilak commented Dec 2, 2024

Hey! :)

I'm on github.com/coralogix/coralogix-management-sdk/go v0.0.0-20240822133107-2f630415357f
it was latest at the time, so around Nov 13, 2024

@celaus
Copy link
Contributor

celaus commented Dec 4, 2024

Fixed with #102

@celaus celaus closed this as completed Dec 4, 2024
@wasilak
Copy link
Author

wasilak commented Dec 4, 2024

Amazing, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants