{"record":{"id":"036b52e513d0dbb7","repo":"grafana/k6","slug":"notify-test-run-completed-w","errorCode":null,"errorMessage":"notify test run completed: %w","messagePattern":"notify test run completed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/cloudapi/provisioning/notify.go","lineNumber":78,"sourceCode":"\t// Authorization: Bearer <token>.\n\tscopedCtx := context.WithValue(ctx, k6cloud.ContextAccessToken, testRunToken)\n\n\tmodel := k6cloud.NewScriptExecutionCompletedNotificationApiModel(\"script_execution_completed\")\n\tif ne := mapTestErrorToNotifyCode(testErr); ne != nil {\n\t\tmodel.SetError(*k6cloud.NewScriptExecutionError(ne.Code, ne.Reason))\n\t} else {\n\t\tmodel.SetErrorNil()\n\t}\n\n\thr, err := c.apiClient.ProvisioningAPI.\n\t\tTestRunsNotify(scopedCtx, testRunID).\n\t\tScriptExecutionCompletedNotificationApiModel(model).\n\t\tExecute()\n\tdefer closeResponse(hr, &err)\n\n\tif hr != nil {\n\t\tif respErr := CheckResponse(hr); respErr != nil {\n\t\t\treturn fmt.Errorf(\"notify test run completed: %w\", respErr)\n\t\t}\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"notify test run completed: %w\", err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":60,"sourceCodeEnd":87,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/provisioning/notify.go#L60-L87","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the wrapped error: status code and body identify the exact refusal","Verify the testRunID and token passed are the ones from the provisioned run's runtime_config","If 401/403, check whether the test ran longer than the scoped token's validity","Check Grafana Cloud status for incidents when 5xx bodies appear"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"func isNotifyHTTPError(err error) bool {\n\tvar re *provisioning.ResponseError\n\treturn err != nil && strings.Contains(err.Error(), \"notify test run completed\") && errors.As(err, &re)\n}","tryCatchPattern":"err := client.NotifyTestRunCompleted(ctx, runID, token, testErr)\nif err != nil {\n\tvar re *provisioning.ResponseError\n\tif errors.As(err, &re) && re.StatusCode >= 500 {\n\t\t// retry with backoff — the notify endpoint is safe to re-post\n\t}\n\t// 4xx: log status/body and continue; the test itself already finished\n}","preventionTips":["Pass the scoped test_run_token from runtime_config verbatim","Retry only 5xx; treat 4xx as configuration/identity problems to fix offline","Log the status code and body whenever notify fails so causes are visible"],"tags":["cloud-api","notify","auth","http","local-execution"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}