{"record":{"id":"58440907cf8e726c","repo":"grafana/k6","slug":"failed-to-get-a-reference-id","errorCode":null,"errorMessage":"failed to get a reference ID","messagePattern":"failed to get a reference ID","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cloudapi/api.go","lineNumber":111,"sourceCode":"func (c *Client) CreateTestRun(testRun *TestRun) (*CreateTestRunResponse, error) {\n\turl := fmt.Sprintf(\"%s/tests\", c.baseURL)\n\n\t// Because the kind of request we make can vary depending on the test run configuration, we delegate\n\t// its creation to a helper.\n\trequest, err := c.makeCreateTestRunRequest(url, testRun)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tresponse := CreateTestRunResponse{}\n\terr = c.Do(request, &response)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tc.handleLogEntriesFromCloud(response)\n\tif response.ReferenceID == \"\" {\n\t\treturn nil, fmt.Errorf(\"failed to get a reference ID\")\n\t}\n\n\treturn &response, nil\n}\n\n// makeCreateTestRunRequest creates a new HTTP request for creating a test run.\n//\n// If the test run archive isn't set, the request will be a regular JSON request with the test run information.\n// Otherwise, the request will be a multipart form request containing the test run information and the archive file.\nfunc (c *Client) makeCreateTestRunRequest(url string, testRun *TestRun) (*http.Request, error) {\n\t// If the test run archive isn't set, we are not uploading an archive and can use the regular request JSON format.\n\tif testRun.Archive == nil {\n\t\treturn c.NewRequest(http.MethodPost, url, testRun)\n\t}\n\n\t// Otherwise, we need to create a multipart form request containing the test run information as\n\t// well as the archive file.\n\tfields := [][2]string{","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/grafana/k6/blob/01ffac6f245854c1b8adc6a69857c76a15f90022/cloudapi/api.go#L93-L129","documentation":"Returned by the cloud API client's CreateTestRun when the POST /tests request technically succeeded (2xx and JSON decoded) but the response contained an empty reference_id — the field that identifies the created test run. Without it the run cannot be tracked.","triggerScenarios":"Thrown at cloudapi/api.go:111 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the Grafana Cloud/k6 Cloud service status and retry the run","Verify the cloud API token and project configuration are correct","Report the issue if it persists — an empty reference_id indicates a server-side problem"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ffac6f245854c1b8adc6a69857c76a15f90022","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}