grafana/k6 · error

serialising archive: %w

Error message

serialising archive: %w

What it means

Client.ProvisionLocalExecution (internal/cloudapi/provisioning/provision.go:72) serialises the lib.Archive into a bytes.Buffer once, both to report its size in the start_local_execution body and to reuse the bytes for the S3 upload. This error means Archive.Write itself failed — an I/O or marshalling problem while walking/emitting the archive contents.

Source

Thrown at internal/cloudapi/provisioning/provision.go:72

// provisioning flow: CreateOrFindLoadTest → StartLocalExecution →
// optional UploadArchive → WaitForTestRunReady.
func (c *Client) ProvisionLocalExecution(ctx context.Context, params ProvisionParams) (*ProvisionResult, error) {
	loadTestID, err := c.v6Client.CreateOrFindLoadTest(ctx, params.ProjectID, params.Name)
	if err != nil {
		return nil, fmt.Errorf("create or find load test: %w", err)
	}

	// Serialise archive once to get its byte-length for the
	// start_local_execution body. The same buffer is reused for
	// the S3 upload to avoid a second serialisation.
	var (
		archiveSize  int64
		archiveBytes []byte
	)
	if params.Archive != nil {
		var buf bytes.Buffer
		if err := params.Archive.Write(&buf); err != nil {
			return nil, fmt.Errorf("serialising archive: %w", err)
		}
		archiveSize = int64(buf.Len())
		archiveBytes = buf.Bytes()
	}

	sleReq := StartLocalExecutionRequest{
		Options:       params.Options,
		MaxVUs:        params.MaxVUs,
		TotalDuration: params.TotalDuration,
		ArchiveSize:   archiveSize,
	}

	sleResp, err := c.StartLocalExecution(ctx, loadTestID, sleReq)
	if err != nil {
		return nil, fmt.Errorf("start local execution: %w", err)
	}

	switch {

View on GitHub (pinned to 93accf6570)

Solutions

  1. Inspect the wrapped error for the failing file or marshalling step
  2. Re-create the archive from a clean checkout and retry
  3. Check read permissions on the script directory and all included files
  4. If reproducible on one machine only, compare filesystem layouts (mounts, symlinks, case sensitivity)
Defensive patterns

Strategy: try-catch

Validate before calling

info, err := params.Archive.Files.Stat() // or equivalent liveness probe
if err != nil {
	return fmt.Errorf("archive sources unreadable before provisioning: %w", err)
}

Try / catch

res, err := client.ProvisionLocalExecution(ctx, params)
if err != nil {
	if strings.Contains(err.Error(), "serialising archive") {
		// re-create the archive from a clean checkout and retry
	}
	return err
}

Prevention

When it happens

Trigger: Source files referenced by the archive became unreadable (permissions changed after archive creation); a path/entry in the archive fails to encode; the buffer write path returns an error (effectively only via the archive's internal file reads).

Common situations: Filesystem or volume permissions changing between archive build and provisioning in containers; scripts referencing files that are deleted/moved mid-run; corrupted archive metadata.

Related errors


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