grafana/k6 · error
couldn't read protoset
Error message
couldn't read protoset: %w
What it means
Raised in Client.LoadProtoset when the protoset file opens successfully but io.ReadAll fails while reading its bytes. The wrapped error gives the I/O reason (permissions, truncation, filesystem fault).
Solutions
- Check the wrapped error for the underlying read failure
- Verify the file is fully readable and not corrupted
- Regenerate the protoset with protoc if it is malformed at the byte level
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/grpc/client.go:113 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/4ec86630071bdc26.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/grpc/client.go:116
if c.vu.State() != nil {
return nil, errors.New("load must be called in the init context")
}
initEnv := c.vu.InitEnv()
if initEnv == nil {
return nil, errors.New("missing init environment")
}
absFilePath := initEnv.GetAbsFilePath(protosetPath)
fdsetFile, err := initEnv.FileSystems["file"].Open(absFilePath)
if err != nil {
return nil, fmt.Errorf("couldn't open protoset: %w", err)
}
defer func() { _ = fdsetFile.Close() }()
fdsetBytes, err := io.ReadAll(fdsetFile)
if err != nil {
return nil, fmt.Errorf("couldn't read protoset: %w", err)
}
fdset := &descriptorpb.FileDescriptorSet{}
if err = proto.Unmarshal(fdsetBytes, fdset); err != nil {
return nil, fmt.Errorf("couldn't unmarshal protoset file %s: %w", protosetPath, err)
}
return c.convertToMethodInfo(fdset)
}
// Note: this function was lifted from `lib/options.go`
func decryptPrivateKey(key, password []byte) ([]byte, error) {
block, _ := pem.Decode(key)
if block == nil {
return nil, errors.New("failed to decode PEM key")
}
blockType := block.TypeView on GitHub (pinned to 8d06114777)