{"record":{"id":"0b294f88d8fda15e","repo":"gohugoio/hugo","slug":"invalid-strict-mode-expected-one-of-error-ignore","errorCode":null,"errorMessage":"invalid strict mode; expected one of error, ignore, or warn; received %s","messagePattern":"invalid strict mode; expected one of error, ignore, or warn; received (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tpl/transform/transform.go","lineNumber":287,"sourceCode":"\t\t\tOutput:           \"mathml\",\n\t\t\tMinRuleThickness: 0.04,\n\t\t\tErrorColor:       \"#cc0000\",\n\t\t\tThrowOnError:     true,\n\t\t\tStrict:           \"error\",\n\t\t},\n\t}\n\n\tif len(args) > 1 {\n\t\tif err := mapstructure.WeakDecode(args[1], &katexInput.Options); err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t}\n\n\tswitch katexInput.Options.Strict {\n\tcase \"error\", \"ignore\", \"warn\":\n\t\t// Valid strict mode, continue\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"invalid strict mode; expected one of error, ignore, or warn; received %s\", katexInput.Options.Strict)\n\t}\n\n\ttype fileCacheEntry struct {\n\t\tVersion  string   `json:\"version\"`\n\t\tOutput   string   `json:\"output\"`\n\t\tWarnings []string `json:\"warnings,omitempty\"`\n\t}\n\n\tconst fileCacheEntryVersion = \"v1\" // Increment on incompatible changes.\n\n\ts := hashing.HashString(args...)\n\tkey := \"tomath/\" + fileCacheEntryVersion + \"/\" + s[:2] + \"/\" + s[2:]\n\tfileCache := ns.deps.ResourceSpec.FileCaches.MiscCache()\n\n\tv, err := ns.cacheMath.GetOrCreate(key, func(string) (template.HTML, error) {\n\t\t_, r, err := fileCache.GetOrCreate(key, func() (io.ReadCloser, error) {\n\t\t\tmessage := warpc.Message[warpc.KatexInput]{\n\t\t\t\tHeader: warpc.Header{","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/tpl/transform/transform.go#L269-L305","documentation":"The transform.ToMath function renders LaTeX via KaTeX with a Strict option. After decoding the options map into KatexOptions (transform.go:283-288), Hugo validates that Strict is exactly one of \"error\", \"ignore\", or \"warn\"; any other value is rejected before dispatching to the WASM KaTeX renderer. The default is \"error\".","triggerScenarios":"Calling {{ transform.ToMath \"x^2\" (dict \"strict\" \"strict\") }} or any value other than error/ignore/warn for the strict key. The switch falls through to the default branch.","commonSituations":"Passing \"true\"/\"false\" assuming boolean handling; passing \"off\" or a typo like \"warning\" instead of \"warn\"; copying KaTeX docs that use different strict values than Hugo exposes.","solutions":["Set strict to one of \"error\", \"ignore\", or \"warn\".","Omit the strict option entirely to use the default \"error\".","Double-check spelling — 'warn' not 'warning', 'ignore' not 'off'."],"exampleFix":"// before\n{{ transform.ToMath \"x^2\" (dict \"strict\" \"warning\") }}\n\n// after\n{{ transform.ToMath \"x^2\" (dict \"strict\" \"warn\") }}","handlingStrategy":"validation","validationCode":"// Always pass one of: error, ignore, warn for the strict option:\n{{ transform.ToMath $expr (dict \"strict\" \"warn\") }}\n// Or omit it to default to \"error\".","typeGuard":"// In Go, before calling, validate the option:\nfunc validStrict(s string) bool {\n    switch s {\n    case \"\", \"error\", \"ignore\", \"warn\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Use exactly 'error', 'ignore', or 'warn' — mind spelling.","Omit strict to accept the 'error' default.","Avoid booleans or synonyms like 'off'/'warning'."],"tags":["transform","tomath","katex","validation","options","template"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}