grafana/k6 · warning

notify test run completed: %w

Error message

notify test run completed: %w

What it means

Client.NotifyTestRunCompleted (internal/cloudapi/provisioning/notify.go:78) reports that POST /provisioning/v1/test_runs/{id}/notify returned a non-2xx status. CheckResponse classifies 401/403 to shared auth sentinels and everything else to a ResponseError carrying status code and body. Notify happens at the end of a local-execution run, authenticated with the scoped test_run_token.

Source

Thrown at internal/cloudapi/provisioning/notify.go:78

	// Authorization: Bearer <token>.
	scopedCtx := context.WithValue(ctx, k6cloud.ContextAccessToken, testRunToken)

	model := k6cloud.NewScriptExecutionCompletedNotificationApiModel("script_execution_completed")
	if ne := mapTestErrorToNotifyCode(testErr); ne != nil {
		model.SetError(*k6cloud.NewScriptExecutionError(ne.Code, ne.Reason))
	} else {
		model.SetErrorNil()
	}

	hr, err := c.apiClient.ProvisioningAPI.
		TestRunsNotify(scopedCtx, testRunID).
		ScriptExecutionCompletedNotificationApiModel(model).
		Execute()
	defer closeResponse(hr, &err)

	if hr != nil {
		if respErr := CheckResponse(hr); respErr != nil {
			return fmt.Errorf("notify test run completed: %w", respErr)
		}
	}
	if err != nil {
		return fmt.Errorf("notify test run completed: %w", err)
	}

	return nil
}

View on GitHub (pinned to 93accf6570)

Solutions

  1. Inspect the wrapped error: status code and body identify the exact refusal
  2. Verify the testRunID and token passed are the ones from the provisioned run's runtime_config
  3. If 401/403, check whether the test ran longer than the scoped token's validity
  4. Check Grafana Cloud status for incidents when 5xx bodies appear
Defensive patterns

Strategy: retry

Type guard

func isNotifyHTTPError(err error) bool {
	var re *provisioning.ResponseError
	return err != nil && strings.Contains(err.Error(), "notify test run completed") && errors.As(err, &re)
}

Try / catch

err := client.NotifyTestRunCompleted(ctx, runID, token, testErr)
if err != nil {
	var re *provisioning.ResponseError
	if errors.As(err, &re) && re.StatusCode >= 500 {
		// retry with backoff — the notify endpoint is safe to re-post
	}
	// 4xx: log status/body and continue; the test itself already finished
}

Prevention

When it happens

Trigger: Expired or invalid test_run_token (401/403); unknown or deleted test run ID (404); malformed notification body (400/422); 5xx persisting after the SDK's built-in retries.

Common situations: Long-running tests whose scoped token expired before completion; the run being force-deleted in the UI while executing; backend incidents; clock skew breaking token validity windows.

Related errors


AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15). Data as JSON: /api/errors/036b52e513d0dbb7. Report an issue: GitHub.