{"record":{"id":"21a35f2a59f913e3","repo":"grafana/k6","slug":"serialising-archive-w","errorCode":null,"errorMessage":"serialising archive: %w","messagePattern":"serialising archive: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloudapi/provisioning/provision.go","lineNumber":72,"sourceCode":"// provisioning flow: CreateOrFindLoadTest → StartLocalExecution →\n// optional UploadArchive → WaitForTestRunReady.\nfunc (c *Client) ProvisionLocalExecution(ctx context.Context, params ProvisionParams) (*ProvisionResult, error) {\n\tloadTestID, err := c.v6Client.CreateOrFindLoadTest(ctx, params.ProjectID, params.Name)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"create or find load test: %w\", err)\n\t}\n\n\t// Serialise archive once to get its byte-length for the\n\t// start_local_execution body. The same buffer is reused for\n\t// the S3 upload to avoid a second serialisation.\n\tvar (\n\t\tarchiveSize  int64\n\t\tarchiveBytes []byte\n\t)\n\tif params.Archive != nil {\n\t\tvar buf bytes.Buffer\n\t\tif err := params.Archive.Write(&buf); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"serialising archive: %w\", err)\n\t\t}\n\t\tarchiveSize = int64(buf.Len())\n\t\tarchiveBytes = buf.Bytes()\n\t}\n\n\tsleReq := StartLocalExecutionRequest{\n\t\tOptions:       params.Options,\n\t\tMaxVUs:        params.MaxVUs,\n\t\tTotalDuration: params.TotalDuration,\n\t\tArchiveSize:   archiveSize,\n\t}\n\n\tsleResp, err := c.StartLocalExecution(ctx, loadTestID, sleReq)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"start local execution: %w\", err)\n\t}\n\n\tswitch {","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/cloudapi/provisioning/provision.go#L54-L90","documentation":"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.","triggerScenarios":"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).","commonSituations":"Filesystem or volume permissions changing between archive build and provisioning in containers; scripts referencing files that are deleted/moved mid-run; corrupted archive metadata.","solutions":["Inspect the wrapped error for the failing file or marshalling step","Re-create the archive from a clean checkout and retry","Check read permissions on the script directory and all included files","If reproducible on one machine only, compare filesystem layouts (mounts, symlinks, case sensitivity)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"info, err := params.Archive.Files.Stat() // or equivalent liveness probe\nif err != nil {\n\treturn fmt.Errorf(\"archive sources unreadable before provisioning: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"res, err := client.ProvisionLocalExecution(ctx, params)\nif err != nil {\n\tif strings.Contains(err.Error(), \"serialising archive\") {\n\t\t// re-create the archive from a clean checkout and retry\n\t}\n\treturn err\n}","preventionTips":["Build archives from immutable checkouts, not live directories","Ensure read permissions on all included files for the runner user","Re-create archives as part of the run pipeline rather than caching them across environment changes"],"tags":["archive","serialization","io","filesystem"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}