Skip to content

Conversation

Gedulis12
Copy link

Added 'KeepLast' to *NoDataStatePropEnum and *ExecErrStatePropEnum on grafana alert rule models. This fixes a bug where if 'Keep Last State' is selected as no data error handling, go client api alert validation fails with error:

noDataState in body should be one of [Alerting NoData OK]

See example code snippet:

func getAlertRules(api *goapi.GrafanaHTTPAPI) (models.ProvisionedAlertRules, error) {
	svc := api.Provisioning
	resp, err := svc.GetAlertRules()
	if err != nil {
		return nil, err
	}
	for _, r := range resp.Payload {
		err = r.Validate(strfmt.Default)
		if err != nil {
			fmt.Println("----------")
			fmt.Println("Validation failed for alert: ", *r.Title, " UID: ", r.UID)
			fmt.Println(*r.NoDataState)
			fmt.Println(err)
		}
	}
	return resp.Payload, nil
}

And stdout:

----------
Validation failed for alert:  <Redacted Title>  UID:  <Redacted Uid>
KeepLast
validation failure list:
noDataState in body should be one of [Alerting NoData OK]

@Gedulis12 Gedulis12 requested a review from a team as a code owner July 2, 2025 11:59
@CLAassistant
Copy link

CLAassistant commented Jul 2, 2025

CLA assistant check
All committers have signed the CLA.

@Gedulis12 Gedulis12 force-pushed the bug/add-no-data-state branch from 9eb28be to a1a4166 Compare July 2, 2025 12:09
nikimanoledaki
nikimanoledaki previously approved these changes Jul 9, 2025
@nikimanoledaki nikimanoledaki self-requested a review July 9, 2025 12:15
@nikimanoledaki nikimanoledaki dismissed their stale review July 9, 2025 12:15

Due to failing check

@Gedulis12
Copy link
Author

@nikimanoledaki i realised i'm not supposed to edit the code directly as it's being generated from the openapispec, i have updated the script pulling and modifying the spec file, can we try running the validation tests again?

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

Successfully merging this pull request may close these issues.

3 participants