grafana/k6 · error
creating a local directory %q: %w
Error message
creating a local directory %q: %w
What it means
Error "creating a local directory %q: %w" thrown in grafana/k6.
Source
Thrown at internal/js/modules/k6/browser/storage/file_persister.go:29
"mime/multipart"
"net/http"
"os"
"path/filepath"
"strings"
"time"
)
// LocalFilePersister will persist files to the local disk.
type LocalFilePersister struct{}
// Persist will write the contents of data to the local disk on the specified path.
// TODO: we should not write to disk here but put it on some queue for async disk writes.
func (l *LocalFilePersister) Persist(_ context.Context, path string, data io.Reader) (err error) {
cp := filepath.Clean(path)
dir := filepath.Dir(cp)
if err = os.MkdirAll(dir, 0o755); err != nil { //nolint:forbidigo,gosec
return fmt.Errorf("creating a local directory %q: %w", dir, err)
}
f, err := os.OpenFile(cp, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600) //nolint:forbidigo
if err != nil {
return fmt.Errorf("creating a local file %q: %w", cp, err)
}
defer func() {
if cerr := f.Close(); cerr != nil && err == nil {
err = fmt.Errorf("closing the local file %q: %w", cp, cerr)
}
}()
bf := bufio.NewWriter(f)
if _, err := io.Copy(bf, data); err != nil {
return fmt.Errorf("copying data to file: %w", err)
}
View on GitHub (pinned to 93accf6570)
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/storage/file_persister.go:29 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/58e3daeaaff82912.
Report an issue: GitHub.