{"id":"b5604ab734b19e86","repo":"evanw/esbuild","slug":"invalid-log-level","errorCode":null,"errorMessage":"Invalid log level","messagePattern":"Invalid log level","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/api/api_impl.go","lineNumber":204,"sourceCode":"\t}\n}\n\nfunc validateLogLevel(value LogLevel) logger.LogLevel {\n\tswitch value {\n\tcase LogLevelVerbose:\n\t\treturn logger.LevelVerbose\n\tcase LogLevelDebug:\n\t\treturn logger.LevelDebug\n\tcase LogLevelInfo:\n\t\treturn logger.LevelInfo\n\tcase LogLevelWarning:\n\t\treturn logger.LevelWarning\n\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 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":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/evanw/esbuild/blob/6ff1d8b0d8c134e867a397eef39702a223ebef9e/pkg/api/api_impl.go#L186-L222","documentation":"A panic raised by validateLogLevel when the LogLevel value is not one of LogLevelVerbose/Debug/Info/Warning/Error/Silent. Internal invariant: only reachable via Go-API misuse producing an out-of-range LogLevel.","triggerScenarios":"Go API: BuildOptions.LogLevel = LogLevel(99). The JS API types LogLevel as a closed string union and cannot reach this panic.","commonSituations":"Reflective config decoding; ordinal drift in a fork; unsafe struct copying across versions.","solutions":["Use only the documented LogLevel constants.","Validate deserialized values against an allowlist.","Do not cast integers to LogLevel.","Pin a single esbuild version."],"exampleFix":"// before\nopts.LogLevel = api.LogLevel(99)\n\n// after\nopts.LogLevel = api.LogLevelInfo","handlingStrategy":"type-guard","validationCode":"func validLogLevel(l api.LogLevel) bool {\n  switch l {\n  case api.LogLevelVerbose, api.LogLevelDebug, api.LogLevelInfo, api.LogLevelWarning, api.LogLevelError, api.LogLevelSilent:\n    return true\n  }\n  return false\n}","typeGuard":"type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'\nfunction isLogLevel(v: unknown): v is LogLevel {\n  return ['verbose','debug','info','warning','error','silent'].includes(v as any)\n}","tryCatchPattern":null,"preventionTips":["Use documented LogLevel constants only.","Validate deserialized config values.","Do not cast integers to LogLevel."],"tags":["api","log-level","panic","invariant","go-api","logging"],"analyzedSha":"6ff1d8b0d8c134e867a397eef39702a223ebef9e","analyzedAt":"2026-08-03T19:42:38.433Z","schemaVersion":2}