grafana/k6 · error

expected bundle type 'js', got

Error message

expected bundle type 'js', got '%s'

What it means

Type guard in NewBundleFromArchive: a lib.Archive's Type field is anything other than 'js'. The archive was created by a different (older or incompatible) tool/k6 version, or the archive metadata is corrupt; k6 cannot build a JS bundle from it.

Solutions

  1. Re-create the archive with a current k6: k6 archive script.js
  2. Verify the .tar archive was produced by k6 and not modified
  3. Upgrade k6 if the archive came from a newer k6 version
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/js/bundle.go:146 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@3fcf5388d7 (2026-08-18). Data as JSON: /api/errors/3ed34324f68f338e. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/bundle.go:146

	if err != nil {
		return nil, err
	}
	bundle.ModuleResolver.Lock()

	err = bundle.populateExports(updateOptions, bi)
	if err != nil {
		return nil, err
	}

	return bundle, nil
}

// NewBundleFromArchive creates a new bundle from an lib.Archive.
func NewBundleFromArchive(
	piState *lib.TestPreInitState, arc *lib.Archive, mr *modules.ModuleResolver,
) (*Bundle, error) {
	if arc.Type != "js" {
		return nil, fmt.Errorf("expected bundle type 'js', got '%s'", arc.Type)
	}

	env := arc.Env
	if env == nil {
		// Older archives (<=0.20.0) don't have an "env" property
		env = make(map[string]string)
	}
	maps.Copy(env, piState.RuntimeOptions.Env)
	piState.RuntimeOptions.Env = env

	return newBundle(piState, &loader.SourceData{
		Data: arc.Data,
		URL:  arc.FilenameURL,
	}, arc.Filesystems, arc.Options, false, mr)
}

func (b *Bundle) makeArchive() *lib.Archive {
	clonedSourceDataURL, _ := url.Parse(b.sourceData.URL.String())

View on GitHub (pinned to 3fcf5388d7)