{"record":{"id":"4ec86630071bdc26","repo":"grafana/k6","slug":"couldn-t-read-protoset-w","errorCode":null,"errorMessage":"couldn't read protoset: %w","messagePattern":"couldn't read protoset: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/modules/k6/grpc/client.go","lineNumber":113,"sourceCode":"\tif c.vu.State() != nil {\n\t\treturn nil, errors.New(\"load must be called in the init context\")\n\t}\n\n\tinitEnv := c.vu.InitEnv()\n\tif initEnv == nil {\n\t\treturn nil, errors.New(\"missing init environment\")\n\t}\n\n\tabsFilePath := initEnv.GetAbsFilePath(protosetPath)\n\tfdsetFile, err := initEnv.FileSystems[\"file\"].Open(absFilePath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't open protoset: %w\", err)\n\t}\n\n\tdefer func() { _ = fdsetFile.Close() }()\n\tfdsetBytes, err := io.ReadAll(fdsetFile)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't read protoset: %w\", err)\n\t}\n\n\tfdset := &descriptorpb.FileDescriptorSet{}\n\tif err = proto.Unmarshal(fdsetBytes, fdset); err != nil {\n\t\treturn nil, fmt.Errorf(\"couldn't unmarshal protoset file %s: %w\", protosetPath, err)\n\t}\n\n\treturn c.convertToMethodInfo(fdset)\n}\n\n// Note: this function was lifted from `lib/options.go`\nfunc decryptPrivateKey(key, password []byte) ([]byte, error) {\n\tblock, _ := pem.Decode(key)\n\tif block == nil {\n\t\treturn nil, errors.New(\"failed to decode PEM key\")\n\t}\n\n\tblockType := block.Type","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/grafana/k6/blob/93accf6570dcd306ca5e99cc44c393ee3797761b/internal/js/modules/k6/grpc/client.go#L95-L131","documentation":"grpc.Client.load() opened the protoset file but io.ReadAll failed while reading its bytes (internal/js/modules/k6/grpc/client.go:113). A pure I/O failure after a successful open - the file is present and opened, but its content could not be read to completion. Rare and usually environmental.","triggerScenarios":"client.load(path) where the opened file becomes unreadable mid-read: truncated or replaced between open and read, storage or permission errors at read time, or a corrupted archive entry that opens but fails to read.","commonSituations":"Data files being rewritten concurrently with test startup; flaky container volumes; partially synced/downloaded protoset files.","solutions":["Regenerate and redeploy the protoset (it may be truncated or corrupted)","Ensure nothing rewrites the file while k6 starts","Move the protoset to local disk next to the script to rule out network storage"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  client.load('./pb/service.protoset');\n} catch (e) {\n  if (/couldn't read protoset/.test(e.message)) {\n    throw new Error('protoset unreadable; regenerate it and ensure nothing rewrites it at startup');\n  }\n  throw e;\n}","preventionTips":["Generate protosets as part of the build, not at run time","Keep them immutable once deployed","Checksum artifacts in CI to catch truncated files"],"tags":["grpc","k6","protoset","io"],"backgroundTag":null,"analyzedSha":"93accf6570dcd306ca5e99cc44c393ee3797761b","analyzedAt":"2026-08-15T21:23:27.118Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}