{"record":{"id":"349b8495d972f8cf","repo":"d2lang/d2","slug":"failed-to-fully-compile-partial-render-written","errorCode":null,"errorMessage":"failed to fully compile (partial render written) %s: %w","messagePattern":"failed to fully compile \\(partial render written\\) (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"d2cli/main.go","lineNumber":418,"sourceCode":"\t\tif err != nil {\n\t\t\treturn xmain.UsageErrorf(\"invalid target: %s\", *targetFlag)\n\t\t}\n\t\tboardPath = key.StringIDA()\n\t}\n\n\tctx, cancel := timelib.WithTimeout(ctx, time.Minute*2)\n\tdefer cancel()\n\n\tanimateInterval := *animateIntervalFlag\n\tif outputFormat == GIF && animateInterval == 0 {\n\t\tanimateInterval = 1000\n\t\tms.Log.Debug.Printf(\"GIF export: animate-interval not specified, defaulting to 1000ms\")\n\t}\n\n\t_, written, err := compile(ctx, ms, plugins, nil, layoutFlag, renderOpts, fontFamily, monoFontFamily, animateInterval, inputPath, outputPath, boardPath, noChildren, *bundleFlag, *forceAppendixFlag, pw.Browser, outputFormat, *asciiModeFlag)\n\tif err != nil {\n\t\tif written {\n\t\t\treturn fmt.Errorf(\"failed to fully compile (partial render written) %s: %w\", ms.HumanPath(inputPath), err)\n\t\t}\n\t\treturn fmt.Errorf(\"failed to compile %s: %w\", ms.HumanPath(inputPath), err)\n\t}\n\treturn nil\n}\n\nfunc LayoutResolver(ctx context.Context, ms *xmain.State, plugins []d2plugin.Plugin) func(engine string) (d2graph.LayoutGraph, error) {\n\tcached := make(map[string]d2graph.LayoutGraph)\n\treturn func(engine string) (d2graph.LayoutGraph, error) {\n\t\tif c, ok := cached[engine]; ok {\n\t\t\treturn c, nil\n\t\t}\n\n\t\tplugin, err := d2plugin.FindPlugin(ctx, plugins, engine)\n\t\tif err != nil {\n\t\t\tif errors.Is(err, exec.ErrNotFound) {\n\t\t\t\treturn nil, layoutNotFound(ctx, plugins, engine)\n\t\t\t}","sourceCodeStart":400,"sourceCodeEnd":436,"githubUrl":"https://github.com/d2lang/d2/blob/0d69dca6f532ceaeacd615d35d1eaa41a238ffdb/d2cli/main.go#L400-L436","documentation":"Run wraps errors from compile() with 'failed to fully compile (partial render written)' when compile reported that an output file was already (partially) written before the failure. The %w-wrapped inner error carries the root cause.","triggerScenarios":"Any compile-time failure (parse, layout, render, export) after the renderer has already written partial output to disk, e.g. multi-board render that wrote some boards then failed.","commonSituations":"Render/export errors mid-multiboard output, interrupted renders leaving stale partial files, plugin failures during the write phase.","solutions":["Read the wrapped inner error (%w chain) for the actual root cause and fix that","Delete the partially written output directory/file before re-running","Re-run with debug logging to locate the stage that failed after writing"],"exampleFix":"// before\n// err: failed to fully compile (partial render written) out/index.svg: ...plugin error...\n// after: inspect inner cause, e.g. fix layout engine name in the .d2 file, then\nd2 input.d2 out.svg","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := d2cli.Run(...); err != nil {\n    var inner error\n    if errors.Unwrap(err) != nil { inner = errors.Unwrap(err) }\n    log.Printf(\"compile failed (partial output may exist): %v; cause: %v\", err, inner)\n    os.RemoveAll(partialOutDir) // clean partial render\n}","preventionTips":["Always inspect errors.Unwrap for the root cause","Clean up partial output directories before re-running","Pre-validate input (.d2 syntax, plugins, browsers) before compile","Wrap runs with retry only after fixing the underlying cause"],"tags":["go","cli","compile","render"],"backgroundTag":"partial-render-write-failure","analyzedSha":"0d69dca6f532ceaeacd615d35d1eaa41a238ffdb","analyzedAt":"2026-08-31T12:19:21.182Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}