{"record":{"id":"198f6c8f1cd471c5","repo":"gohugoio/hugo","slug":"invalid-font-source-s","errorCode":null,"errorMessage":"invalid font source: %s","messagePattern":"invalid font source: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/filters.go","lineNumber":116,"sourceCode":"\t\t\t\ttf.x = cast.ToInt(v)\n\t\t\tcase \"y\":\n\t\t\t\ttf.y = cast.ToInt(v)\n\t\t\tcase \"alignx\":\n\t\t\t\ttf.alignx = cast.ToString(v)\n\t\t\t\tif tf.alignx != \"left\" && tf.alignx != \"center\" && tf.alignx != \"right\" {\n\t\t\t\t\tpanic(\"alignx must be one of left, center, right\")\n\t\t\t\t}\n\t\t\tcase \"aligny\":\n\t\t\t\ttf.aligny = cast.ToString(v)\n\t\t\t\tif tf.aligny != \"top\" && tf.aligny != \"center\" && tf.aligny != \"bottom\" {\n\t\t\t\t\tpanic(\"aligny must be one of top, center, bottom\")\n\t\t\t\t}\n\n\t\t\tcase \"linespacing\":\n\t\t\t\ttf.linespacing = cast.ToInt(v)\n\t\t\tcase \"font\":\n\t\t\t\tif err, ok := v.(error); ok {\n\t\t\t\t\tpanic(fmt.Sprintf(\"invalid font source: %s\", err))\n\t\t\t\t}\n\t\t\t\tfontSource, ok1 := v.(hugio.ReadSeekCloserProvider)\n\t\t\t\tidentifier, ok2 := v.(resource.Identifier)\n\n\t\t\t\tif !(ok1 && ok2) {\n\t\t\t\t\tpanic(fmt.Sprintf(\"invalid text font source: %T\", v))\n\t\t\t\t}\n\n\t\t\t\ttf.fontSource = fontSource\n\n\t\t\t\t// The input value isn't hashable and will not make a stable key.\n\t\t\t\t// Replace it with a string in the map used as basis for the\n\t\t\t\t// hash string.\n\t\t\t\topt[\"font\"] = identifier.Key()\n\n\t\t\t}\n\t\t}\n\t}","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/filters.go#L98-L134","documentation":"Thrown by images.Text when the `font` option resolves to a value that implements the `error` interface (filters.go:115-117). This indicates the font resource itself failed to load/resolve and the error object was passed through instead of a usable font source, so the filter refuses to proceed.","triggerScenarios":"Passing a resource lookup that returned an error (e.g. a failed resources.Get or a malformed resources.GetRemote result) directly as the `font` argument. The type switch detects the error type first and panics with the underlying error message.","commonSituations":"Font file is missing from assets/, the path is wrong, GetRemote returned a non-200 response whose error is forwarded, or a resources.Concat/FromString produced an error that was not checked before being handed to Text.","solutions":["Check the font resource for an error before passing it to images.Text.","Verify the font file exists under assets/ and the path used in resources.Get is correct.","If fetching remotely, confirm the URL returns 200 and a valid font before forwarding it."],"exampleFix":"// before\n{{ $f := resources.GetRemote \"https://example.com/font.woff\" }}\n{{ $filters = $filters | append (images.Text \"Hi\" (dict \"font\" $f)) }}\n// after\n{{ $f := resources.GetRemote \"https://example.com/font.woff\" }}\n{{ if $f.Err }}{{ errorf \"font load failed: %v\" $f.Err }}{{ end }}\n{{ $filters = $filters | append (images.Text \"Hi\" (dict \"font\" $f)) }}","handlingStrategy":"validation","validationCode":"{{ $f := resources.GetRemote \"https://example.com/font.woff\" }}\n{{ with $f.Err }}\n  {{ errorf \"font fetch failed: %v\" . }}\n{{ end }}","typeGuard":"// AsError reports whether v carries a load error (implements error).\nfunc AsError(v any) bool { _, ok := v.(error); return ok }","tryCatchPattern":null,"preventionTips":["Always check resources.GetRemote/.Err and resources.FromString errors before forwarding to Text.","Log the underlying font error so the cause is visible.","Provide a fallback font resource when the primary may fail."],"tags":["image-filter","text-rendering","font","resource-loading","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}