{"record":{"id":"3ed34324f68f338e","repo":"grafana/k6","slug":"expected-bundle-type-js-got-s","errorCode":null,"errorMessage":"expected bundle type 'js', got '%s'","messagePattern":"expected bundle type 'js', got '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/bundle.go","lineNumber":146,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tbundle.ModuleResolver.Lock()\n\n\terr = bundle.populateExports(updateOptions, bi)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn bundle, nil\n}\n\n// NewBundleFromArchive creates a new bundle from an lib.Archive.\nfunc NewBundleFromArchive(\n\tpiState *lib.TestPreInitState, arc *lib.Archive, mr *modules.ModuleResolver,\n) (*Bundle, error) {\n\tif arc.Type != \"js\" {\n\t\treturn nil, fmt.Errorf(\"expected bundle type 'js', got '%s'\", arc.Type)\n\t}\n\n\tenv := arc.Env\n\tif env == nil {\n\t\t// Older archives (<=0.20.0) don't have an \"env\" property\n\t\tenv = make(map[string]string)\n\t}\n\tmaps.Copy(env, piState.RuntimeOptions.Env)\n\tpiState.RuntimeOptions.Env = env\n\n\treturn newBundle(piState, &loader.SourceData{\n\t\tData: arc.Data,\n\t\tURL:  arc.FilenameURL,\n\t}, arc.Filesystems, arc.Options, false, mr)\n}\n\nfunc (b *Bundle) makeArchive() *lib.Archive {\n\tclonedSourceDataURL, _ := url.Parse(b.sourceData.URL.String())","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/grafana/k6/blob/3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee/internal/js/bundle.go#L128-L164","documentation":"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.","triggerScenarios":"Thrown at internal/js/bundle.go:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-create the archive with a current k6: k6 archive script.js","Verify the .tar archive was produced by k6 and not modified","Upgrade k6 if the archive came from a newer k6 version"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fcf5388d78cb382f0c0d42ec556a06bfd1b8dee","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}