grafana/k6 · error

failed to get a reference ID

Error message

failed to get a reference ID

What it means

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.

Solutions

  1. Check the Grafana Cloud/k6 Cloud service status and retry the run
  2. Verify the cloud API token and project configuration are correct
  3. Report the issue if it persists — an empty reference_id indicates a server-side problem
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at cloudapi/api.go:111 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/58440907cf8e726c. Report an issue: GitHub.

Appendix: source

Thrown at cloudapi/api.go:111

func (c *Client) CreateTestRun(testRun *TestRun) (*CreateTestRunResponse, error) {
	url := fmt.Sprintf("%s/tests", c.baseURL)

	// Because the kind of request we make can vary depending on the test run configuration, we delegate
	// its creation to a helper.
	request, err := c.makeCreateTestRunRequest(url, testRun)
	if err != nil {
		return nil, err
	}

	response := CreateTestRunResponse{}
	err = c.Do(request, &response)
	if err != nil {
		return nil, err
	}

	c.handleLogEntriesFromCloud(response)
	if response.ReferenceID == "" {
		return nil, fmt.Errorf("failed to get a reference ID")
	}

	return &response, nil
}

// makeCreateTestRunRequest creates a new HTTP request for creating a test run.
//
// If the test run archive isn't set, the request will be a regular JSON request with the test run information.
// Otherwise, the request will be a multipart form request containing the test run information and the archive file.
func (c *Client) makeCreateTestRunRequest(url string, testRun *TestRun) (*http.Request, error) {
	// If the test run archive isn't set, we are not uploading an archive and can use the regular request JSON format.
	if testRun.Archive == nil {
		return c.NewRequest(http.MethodPost, url, testRun)
	}

	// Otherwise, we need to create a multipart form request containing the test run information as
	// well as the archive file.
	fields := [][2]string{

View on GitHub (pinned to 01ffac6f24)