{"record":{"id":"7cd0ba78cb09499d","repo":"d2lang/d2","slug":"code-snippet-style-github-not-found","errorCode":null,"errorMessage":"code snippet style \"github\" not found","messagePattern":"code snippet style \"github\" not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2renderers/d2svg/d2svg.go","lineNumber":1286,"sourceCode":"\t\t\t\tconnection.LabelHeight,\n\t\t\t\tconnection.GetFontColor(),\n\t\t\t\tconnection.Fill,\n\t\t\t\tconnection.Link != \"\",\n\t\t\t\tconnection.Underline,\n\t\t\t))\n\t\t} else if connection.Language != \"\" {\n\t\t\tlexer := lexers.Get(connection.Language)\n\t\t\tif lexer == nil {\n\t\t\t\tlexer = lexers.Fallback\n\t\t\t}\n\t\t\tfor _, isLight := range []bool{true, false} {\n\t\t\t\ttheme := \"github\"\n\t\t\t\tif !isLight {\n\t\t\t\t\ttheme = \"catppuccin-mocha\"\n\t\t\t\t}\n\t\t\t\tstyle := styles.Get(theme)\n\t\t\t\tif style == nil {\n\t\t\t\t\treturn labelMask, errors.New(`code snippet style \"github\" not found`)\n\t\t\t\t}\n\t\t\t\titerator, err := lexer.Tokenise(nil, connection.Label)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn labelMask, err\n\t\t\t\t}\n\n\t\t\t\tsvgStyles := styleToSVG(style)\n\t\t\t\tclass := \"light-code\"\n\t\t\t\tif !isLight {\n\t\t\t\t\tclass = \"dark-code\"\n\t\t\t\t}\n\t\t\t\tvar fontSize string\n\t\t\t\tif connection.FontSize != d2fonts.FONT_SIZE_M {\n\t\t\t\t\tfontSize = fmt.Sprintf(` style=\"font-size:%v\"`, connection.FontSize)\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(writer, `<g transform=\"translate(%f %f)\" class=\"%s\"%s>`,\n\t\t\t\t\tlabelTL.X, labelTL.Y, class, fontSize,\n\t\t\t\t)","sourceCodeStart":1268,"sourceCodeEnd":1304,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2renderers/d2svg/d2svg.go#L1268-L1304","documentation":"When drawing a connection whose label is rendered as a code snippet, d2svg looks up a syntax-highlighting style from the embedded chroma style registry ('github' for light, 'catppuccin-mocha' for dark). If the style is missing from the registry (e.g. build without embedded styles or an unexpected registry state), drawConnection returns this error and the connection label mask cannot be produced.","triggerScenarios":"Rendering a diagram containing a connection (edge) with a code/markdown label via d2svg.Render, where styles.Get(\"github\") or styles.Get(\"catppuccin-mocha\") returns nil — i.e. the chroma styles registry does not contain the embedded theme.","commonSituations":"Custom or stripped-down builds of chroma that exclude embedded styles; vendoring/importing a different chroma version where style names changed; mis-assembled binaries missing embedded assets.","solutions":["Ensure the chroma dependency includes embedded styles (import _ 'github.com/alecthomas/chroma/v2/styles' side-effect package)","Verify the chroma version used provides 'github' and 'catppuccin-mocha' styles; upgrade or pin a compatible version","Check that build tooling (e.g. go mod vendor) did not strip embedded style assets"],"exampleFix":"// before\nimport \"github.com/alecthomas/chroma/v2\"\n// after (ensure styles registry is populated)\nimport _ \"github.com/alecthomas/chroma/v2/styles\"","handlingStrategy":"fallback","validationCode":"if chromastyles.Get(\"github\") == nil || chromastyles.Get(\"catppuccin-mocha\") == nil {\n    return errors.New(\"chroma styles registry missing required themes\")\n}","typeGuard":"func hasChromaStyle(name string) bool {\n    return chromastyles.Get(name) != nil\n}","tryCatchPattern":"labelMask, err := d2svg.Render(diagram, opts)\nif err != nil && strings.Contains(err.Error(), \"code snippet style\") {\n    // fall back to plain-text labels or fix embedded style imports\n}","preventionTips":["Blank-import chroma styles package in renderer consumers","Pin a chroma version that includes 'github' and 'catppuccin-mocha'","Smoke-test SVG rendering of code-snippet labels in CI"],"tags":["svg","rendering","syntax-highlighting"],"backgroundTag":"chroma-style-not-found","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}