{"record":{"id":"889aaa7f078289aa","repo":"mudler/LocalAI","slug":"failed-to-write-image-to-s-n","errorCode":null,"errorMessage":"Failed to write image to '%s'\\n","messagePattern":"Failed to write image to '(.+?)'\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/go/stablediffusion-ggml/cpp/gosd.cpp","lineNumber":1046,"sourceCode":"            if (buffer) free(buffer);\n        }\n        return 1;\n    }\n\n    fprintf (stderr, \"Writing PNG\\n\");\n\n    fprintf (stderr, \"DST: %s\\n\", dst);\n    fprintf (stderr, \"Width: %d\\n\", results[0].width);\n    fprintf (stderr, \"Height: %d\\n\", results[0].height);\n    fprintf (stderr, \"Channel: %d\\n\", results[0].channel);\n    fprintf (stderr, \"Data: %p\\n\", results[0].data);\n\n    int ret = stbi_write_png(dst, results[0].width, results[0].height, results[0].channel,\n                             results[0].data, 0);\n    if (ret)\n      fprintf (stderr, \"Saved resulting image to '%s'\\n\", dst);\n    else\n      fprintf(stderr, \"Failed to write image to '%s'\\n\", dst);\n\n    // Clean up\n    free(results[0].data);\n    results[0].data = NULL;\n    free(results);\n    if (input_image_buffer) free(input_image_buffer);\n    if (mask_image_buffer) free(mask_image_buffer);\n    for (auto buffer : ref_image_buffers) {\n        if (buffer) free(buffer);\n    }\n    fprintf (stderr, \"gen_image is done: %s\\n\", dst);\n    fflush(stderr);\n\n    return !ret;\n}\n\n// ---------------- Video generation ----------------\n","sourceCodeStart":1028,"sourceCodeEnd":1064,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/stablediffusion-ggml/cpp/gosd.cpp#L1028-L1064","documentation":"Writing the generated image to the output path failed. Guard: ensure the output directory exists and is writable before generation; check the write result and return an error naming the path.","triggerScenarios":"Thrown at backend/go/stablediffusion-ggml/cpp/gosd.cpp:1046 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the output directory exists and is writable by the backend process.","Check available disk space on the output volume.","Confirm the output path is valid for the platform."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}