{"record":{"id":"a33b60eb04fbc2de","repo":"evanw/esbuild","slug":"invalid-log-style","errorCode":null,"errorMessage":"Invalid log style","messagePattern":"Invalid log style","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/api/api_impl.go","lineNumber":217,"sourceCode":"\tcase LogLevelError:\n\t\treturn logger.LevelError\n\tcase LogLevelSilent:\n\t\treturn logger.LevelSilent\n\tdefault:\n\t\tpanic(\"Invalid log level\")\n\t}\n}\n\nfunc validateLogStyle(value LogStyle) logger.LogStyle {\n\tswitch value {\n\tcase LogStyleDefault:\n\t\treturn logger.StyleDefault\n\tcase LogStyleClang:\n\t\treturn logger.StyleClang\n\tcase LogStyleVisualStudio:\n\t\treturn logger.StyleVisualStudio\n\tdefault:\n\t\tpanic(\"Invalid log style\")\n\t}\n}\n\nfunc validateASCIIOnly(value Charset) bool {\n\tswitch value {\n\tcase CharsetDefault, CharsetASCII:\n\t\treturn true\n\tcase CharsetUTF8:\n\t\treturn false\n\tdefault:\n\t\tpanic(\"Invalid charset\")\n\t}\n}\n\nfunc validateExternalPackages(value Packages) bool {\n\tswitch value {\n\tcase PackagesDefault, PackagesBundle:\n\t\treturn false","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/pkg/api/api_impl.go#L199-L235","documentation":"validateLogStyle (pkg/api/api_impl.go:217) panics when LogStyle is not LogStyleDefault(0), LogStyleClang(1), or LogStyleVisualStudio(2). The style controls the diagnostic message formatting (file:line:column layout) emitted by the logger; an undefined value would corrupt error output, so esbuild aborts. Reached from contextImpl while constructing logger.OutputOptions.","triggerScenarios":"Assigning LogStyle from an out-of-range integer, deserializing it from a numeric wire format, or using a stale/imagined constant such as `api.LogStyleMSBuild`. The panic fires during options normalization, before any parsing.","commonSituations":"Editor/IDE integrations that pipe a `--log-style` flag with a numeric mapping that drifted across versions, persisted config files that store LogStyle as a number, or copy-paste from outdated docs.","solutions":["Use api.LogStyleDefault (zero value) or api.LogStyleClang / api.LogStyleVisualStudio.","Bounds-check any integer destined for LogStyle against 0..2.","Store the preference as a string and map to the constant at load.","Keep esbuild versions aligned across all consumers of the API."],"exampleFix":"// before\nopts := api.BuildOptions{LogStyle: api.LogStyle(5)}\n\n// after\nopts := api.BuildOptions{LogStyle: api.LogStyleDefault}","handlingStrategy":"validation","validationCode":"func checkLogStyle(ls api.LogStyle) error {\n    switch ls {\n    case api.LogStyleDefault, api.LogStyleClang, api.LogStyleVisualStudio:\n        return nil\n    }\n    return fmt.Errorf(\"invalid log style %d (want 0..2)\", uint8(ls))\n}","typeGuard":"func isValidLogStyle(ls api.LogStyle) bool {\n    switch ls {\n    case api.LogStyleDefault, api.LogStyleClang, api.LogStyleVisualStudio:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Use the zero value LogStyleDefault unless you specifically need IDE-friendly output.","Bounds-check integers from inter-process config to 0..2.","Map editor/IDE preferences to constants rather than passing raw ordinals.","Re-vendor bridges alongside the core after any esbuild bump."],"tags":["esbuild","config","validation","panic","log-style","logger","enum"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}