{"record":{"id":"2025c66c4cd20f3c","repo":"grafana/k6","slug":"an-error-occurred-communicating-with-the-provision","errorCode":null,"errorMessage":"an error occurred communicating with the provisioning API","messagePattern":"an error occurred communicating with the provisioning API","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/provisioning/errors.go","lineNumber":12,"sourceCode":"package provisioning\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\n\t\"go.k6.io/k6/v2/internal/cloudapi/httperr\"\n)\n\nvar errUnknown = errors.New(\"an error occurred communicating with the provisioning API\")\n\n// ResponseError represents an error returned by the provisioning API.\ntype ResponseError struct {\n\tStatusCode int\n\tBody       string\n}\n\nfunc (e *ResponseError) Error() string {\n\treturn fmt.Sprintf(\"provisioning API error (%d): %s\", e.StatusCode, e.Body)\n}\n\n// CheckResponse checks an HTTP response from the provisioning API.\n// It returns nil if the status code is in the 2xx range, otherwise it\n// returns a *ResponseError with the status code and response body.\nfunc CheckResponse(resp *http.Response) error {\n\tif resp == nil {\n\t\treturn errUnknown\n\t}","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/internal/cloudapi/provisioning/errors.go#L1-L30","documentation":"After the isDisabled action succeeds (frame.go:1512), k6 asserts the result is a bool and returns 'checking is %q disabled: unexpected type %T' when it is not. Since waitForElementState returns a Go bool, a non-bool (usually nil) means the action machinery returned an unexpected value: a race with frame detachment/navigation, or a bug in the k6 browser module's value handling. Like the other 'unexpected type' state checks, it is an internal invariant break rather than an application state.","triggerScenarios":"Frame detaches or navigates between selector resolution and result delivery; nil value on a rare error path; CDP session teardown races; browser-module regression.","commonSituations":"Intermittent CI failures during page transitions; SPA iframe swaps racing the check; first appearances after a k6 upgrade.","solutions":["Retry once after letting the page settle (waitForLoadState or locator.waitFor).","Ensure no navigation is triggered concurrently with the check.","Enable K6_DEBUG=true to correlate the race with navigation events.","File a grafana/k6 issue with a reproducible script if it persists."],"exampleFix":"// before\nconst off = await page.isDisabled('#submit');\n\n// after\nawait page.waitForLoadState('domcontentloaded');\nlet off;\ntry { off = await page.isDisabled('#submit'); }\ncatch (e) {\n  if (!String(e).includes('unexpected type')) throw e;\n  off = await page.isDisabled('#submit'); // single retry\n}","handlingStrategy":"retry","validationCode":"await page.waitForLoadState('domcontentloaded');","typeGuard":null,"tryCatchPattern":"try {\n  return await page.isDisabled(sel);\n} catch (e) {\n  if (!String(e).includes('unexpected type')) throw e;\n  await page.waitForLoadState('domcontentloaded');\n  return await page.isDisabled(sel); // retry once past the race\n}","preventionTips":["Don't fire state checks while navigation or iframe replacement is in progress.","Stabilize with waitForLoadState before asserting.","Collect K6_DEBUG logs for flaky cases and report stable repros to grafana/k6."],"tags":["k6","browser","isdisabled","type-assertion","race"],"backgroundTag":"unexpected-eval-return-type","analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}