{"id":"4915bfc60bdd1ab1","repo":"gin-gonic/gin","slug":"gin-mode-unknown-value-available-mode-debug","errorCode":null,"errorMessage":"gin mode unknown: ${value} (available mode: debug release test)","messagePattern":"gin mode unknown: (.+?) \\(available mode: debug release test\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"mode.go","lineNumber":75,"sourceCode":"// SetMode sets gin mode according to input string.\nfunc SetMode(value string) {\n\tif value == \"\" {\n\t\tif flag.Lookup(\"test.v\") != nil {\n\t\t\tvalue = TestMode\n\t\t} else {\n\t\t\tvalue = DebugMode\n\t\t}\n\t}\n\n\tswitch value {\n\tcase DebugMode:\n\t\tatomic.StoreInt32(&ginMode, debugCode)\n\tcase ReleaseMode:\n\t\tatomic.StoreInt32(&ginMode, releaseCode)\n\tcase TestMode:\n\t\tatomic.StoreInt32(&ginMode, testCode)\n\tdefault:\n\t\tpanic(\"gin mode unknown: \" + value + \" (available mode: debug release test)\")\n\t}\n\tmodeName.Store(value)\n}\n\n// DisableBindValidation closes the default validator.\nfunc DisableBindValidation() {\n\tbinding.Validator = nil\n}\n\n// EnableJsonDecoderUseNumber sets true for binding.EnableDecoderUseNumber to\n// call the UseNumber method on the JSON Decoder instance.\nfunc EnableJsonDecoderUseNumber() {\n\tbinding.EnableDecoderUseNumber = true\n}\n\n// EnableJsonDecoderDisallowUnknownFields sets true for binding.EnableDecoderDisallowUnknownFields to\n// call the DisallowUnknownFields method on the JSON Decoder instance.\nfunc EnableJsonDecoderDisallowUnknownFields() {","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/gin-gonic/gin/blob/34dac209ffb6ef85cc78c5d217bbb7ad001d68fd/mode.go#L57-L93","documentation":"SetMode (mode.go:75) panics with this message when the supplied mode string (or the GIN_MODE env var, read in init()) is not one of debug/release/test. Because init() calls SetMode(os.Getenv(\"GIN_MODE\")), a bad GIN_MODE value panics at program startup before main runs.","triggerScenarios":"Setting GIN_MODE=production (should be release) in the environment or Dockerfile; calling gin.SetMode(\"PROD\") with wrong case or spelling; importing gin in a binary whose env exports GIN_MODE=Release.","commonSituations":"Container/Dockerfile ENV GIN_MODE=production (common mistake — the release value is \"release\"); CI config that upper-cases the value; copy-paste from docs that say \"production mode\".","solutions":["Use exactly one of: debug, release, test (case-sensitive, lowercase). For production use GIN_MODE=release.","Unset GIN_MODE (or pass \"\") to fall back to debug (or test when running under `go test -v`).","If you set the mode in code, call gin.SetMode(gin.ReleaseMode) using the constant, not a literal."],"exampleFix":"// before\n# Dockerfile\nENV GIN_MODE=production\n// after\nENV GIN_MODE=release","handlingStrategy":"validation","validationCode":"switch os.Getenv(gin.EnvGinMode) {\ncase \"\", gin.DebugMode, gin.ReleaseMode, gin.TestMode:\n    // ok\ndefault:\n    log.Fatalf(\"GIN_MODE=%q is invalid; use one of debug|release|test\", os.Getenv(gin.EnvGinMode))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the constants gin.DebugMode / gin.ReleaseMode / gin.TestMode in code.","Audit Dockerfiles and CI for GIN_MODE=production (the wrong value); it must be release.","Leave GIN_MODE unset in dev to fall back to debug automatically."],"tags":["mode","configuration","startup","panic","go"],"analyzedSha":"34dac209ffb6ef85cc78c5d217bbb7ad001d68fd","analyzedAt":"2026-08-04T21:26:18.438Z","schemaVersion":2}