{"record":{"id":"7233075c5b7b32e3","repo":"Billionmail/BillionMail","slug":"imagemagick-annotate-failed-w-noutput-s","errorCode":null,"errorMessage":"imagemagick annotate failed: %w\\noutput: %s","messagePattern":"imagemagick annotate failed: %w\\\\noutput: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/video_gen/annotate.go","lineNumber":101,"sourceCode":"\t\t\t\tType: AnnotationText,\n\t\t\t\tX:    100, Y: 950,\n\t\t\t\tText:  \"High ad spend but room for improvement\",\n\t\t\t\tColor: \"#FF6600\",\n\t\t\t})\n\t\t}\n\t\treturn anns\n\t}\n\treturn nil\n}\n\n// Annotate applies visual annotations to a screenshot using ImageMagick.\n// Requires: convert (ImageMagick) installed.\nfunc Annotate(ctx context.Context, cfg AnnotateConfig) error {\n\targs := BuildAnnotateArgs(cfg)\n\tcmd := exec.CommandContext(ctx, \"magick\", args...)\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"imagemagick annotate failed: %w\\noutput: %s\", err, string(out))\n\t}\n\treturn nil\n}\n\n// BuildAnnotateArgs constructs the ImageMagick CLI arguments for the given config.\n// Exported for testing without requiring ImageMagick installed.\nfunc BuildAnnotateArgs(cfg AnnotateConfig) []string {\n\targs := []string{cfg.InputPath}\n\n\tfor _, ann := range cfg.Annotations {\n\t\tcolor := ann.Color\n\t\tif color == \"\" {\n\t\t\tcolor = \"red\"\n\t\t}\n\n\t\tswitch ann.Type {\n\t\tcase AnnotationCircle:\n\t\t\t// Draw a circle outline","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/video_gen/annotate.go#L83-L119","documentation":"Annotate shells out to ImageMagick's `magick` CLI to draw annotations onto an image. If the command exits non-zero, it wraps the exec error together with the combined stdout/stderr so the caller can see why ImageMagick failed. It is thrown for any magick invocation failure: missing binary, unreadable input, bad arguments, or ImageMagick processing errors.","triggerScenarios":"exec.CommandContext(ctx, \"magick\", args...) returns a non-nil error — magick not installed/not on PATH, input file missing or unreadable, invalid annotate arguments, disk full, or context cancelled before completion.","commonSituations":"ImageMagick not installed in the container/host (video_gen requires it); typo'd image path; policy.xml restricting operations; arguments producing an option error visible in `output`; context deadline exceeded on large images.","solutions":["Install ImageMagick 7 (which provides `magick`) and ensure it is on PATH: apt-get install imagemagick (v7) or imagemagick7","Check the `output:` portion of the error for the specific magick CLI complaint","Verify the input file exists and is readable, and the output directory is writable","Run the BuildAnnotateArgs output manually to reproduce: magick <args...>","If the error is 'signal: killed' or context deadline, increase the timeout or image size limits"],"exampleFix":"// before (CI Dockerfile)\nFROM golang:1.22\n// after\nFROM golang:1.22\nRUN apt-get update && apt-get install -y imagemagick && rm -rf /var/lib/apt/lists/*","handlingStrategy":"try-catch","validationCode":"func magickAvailable() error {\n    path, err := exec.LookPath(\"magick\")\n    if err != nil { return fmt.Errorf(\"ImageMagick v7 'magick' not on PATH: %w\", err) }\n    return nil\n}\n// also pre-check: file exists\nif _, err := os.Stat(cfg.InputPath); err != nil { return err }","typeGuard":null,"tryCatchPattern":"if err := video_gen.Annotate(ctx, cfg); err != nil {\n    var ee *exec.ExitError\n    if errors.As(err, &ee) {\n        log.Printf(\"magick failed (exit %d): %s\", ee.ExitCode(), err)\n        return fmt.Errorf(\"install ImageMagick or fix args: %w\", err)\n    }\n    return err\n}","preventionTips":["Install ImageMagick 7 in every environment running video_gen (add to Dockerfile)","Pre-flight exec.LookPath(\"magick\") at service startup","Verify input/output paths exist and are writable before calling Annotate","Keep annotation configs validated (BuildAnnotateArgs is exported for testing)"],"tags":["imagemagick","exec","external-command","video-gen"],"backgroundTag":"external-command-failed","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}