{"record":{"id":"2e9311cb62812e16","repo":"sqshq/sampler","slug":"failed-to-load-the-font","errorCode":null,"errorMessage":"Failed to load the font: ","messagePattern":"Failed to load the font: ","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"component/asciibox/asciibox.go","lineNumber":36,"sourceCode":"\t*data.Consumer\n\talert   *data.Alert\n\tascii   string\n\tstyle   ui.Style\n\trender  *fl.AsciiRender\n\toptions *fl.RenderOptions\n\tpalette console.Palette\n}\n\nconst asciiFontExtension = \".flf\"\n\nfunc NewAsciiBox(c config.AsciiBoxConfig, palette console.Palette) *AsciiBox {\n\n\toptions := fl.NewRenderOptions()\n\toptions.FontName = string(*c.Font)\n\n\tfontStr, err := asset.Asset(options.FontName + asciiFontExtension)\n\tif err != nil {\n\t\tpanic(\"Failed to load the font: \" + err.Error())\n\t}\n\n\trender := fl.NewAsciiRender()\n\t_ = render.LoadBindataFont(fontStr, options.FontName)\n\n\tcolor := c.Color\n\tif color == nil {\n\t\tcolor = &palette.BaseColor\n\t}\n\n\tbox := AsciiBox{\n\t\tBlock:    component.NewBlock(c.Title, *c.Border, palette),\n\t\tConsumer: data.NewConsumer(),\n\t\tstyle:    ui.NewStyle(*color),\n\t\trender:   render,\n\t\toptions:  options,\n\t\tpalette:  palette,\n\t}","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/sqshq/sampler/blob/9bc7ba732d31f32a917ad4b5605f00b76ebe0891/component/asciibox/asciibox.go#L18-L54","documentation":"NewAsciiBox panics when the embedded font file (font name + \".flf\") cannot be loaded from the bundled assets. The component requires one of the known figlet-style fonts embedded in the binary, so an unknown font name in the config is a hard startup failure for that component.","triggerScenarios":"Configuring an ascii-box component with a font value whose <font>.flf is not present in the embedded asset store; asset.Asset(options.FontName+asciiFontExtension) returns an error and the code panics.","commonSituations":"Typo in the YAML font field; copying a config from another project using different font names; expecting a custom font to be available when only built-in fonts are embedded.","solutions":["Set the font to one of the supported built-in names (e.g. standard, big, block, shadow...) exactly as shipped","Check the embedded asset list / repo fonts directory for valid font file names","Wrap NewAsciiBox/startAll with recover or pre-validate the font value before constructing the component","Add the desired .flf font to the embedded assets if a custom font is genuinely needed"],"exampleFix":"// before\nfont: BigFinale\ncolor: red\n// after\nfont: standard  # supported embedded font\ncolor: red","handlingStrategy":"validation","validationCode":"var supportedFonts = map[string]bool{\"standard\": true, \"big\": true, \"block\": true, \"shadow\": true}\nif !supportedFonts[strings.ToLower(cfg.Font)] { cfg.Font = ptr(\"standard\") }","typeGuard":"func fontAvailable(name string) bool {\n    _, err := asset.Asset(name + \".flf\")\n    return err == nil\n}","tryCatchPattern":"func newBoxSafe(cfg *Cfg) (box *asciibox.AsciiBox, err error) {\n    defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"ascii box init failed: %v\", r) } }()\n    return asciibox.NewAsciiBox(cfg), nil\n}","preventionTips":["Validate font names against the embedded list at config load","Keep font values in sync with the shipped .flf assets","Fail fast at startup with a clear message listing valid fonts"],"tags":["go","panic","font","config","embedded-assets"],"backgroundTag":"file-not-found","analyzedSha":"9bc7ba732d31f32a917ad4b5605f00b76ebe0891","analyzedAt":"2026-09-06T08:38:02.595Z","contentChangedAt":"2026-09-06T08:38:02.595Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}