{"record":{"id":"d17957f9e66ff233","repo":"mudler/LocalAI","slug":"invalid-sample-method-using-default-s-n","errorCode":null,"errorMessage":"Invalid sample method, using default: %s\\n","messagePattern":"Invalid sample method, using default: (.+?)\\\\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"backend/go/stablediffusion-ggml/cpp/gosd.cpp","lineNumber":690,"sourceCode":"    ctx_params.model_args = model_args_spec.c_str();\n    sd_ctx_t* sd_ctx = new_sd_ctx(&ctx_params);\n\n    if (sd_ctx == NULL) {\n        fprintf (stderr, \"failed loading model (generic error)\\n\");\n        // TODO: Clean up allocated memory\n        return 1;\n    }\n    fprintf (stderr, \"Created context: OK\\n\");\n\n    int sample_method_found = -1;\n    sample_method_t sm = str_to_sample_method(sampler);\n    if (sm != SAMPLE_METHOD_COUNT) {\n        sample_method_found = (int)sm;\n        fprintf(stderr, \"Found sampler: %s\\n\", sampler);\n    }\n    if (sample_method_found == -1) {\n        sample_method_found = sd_get_default_sample_method(sd_ctx);\n        fprintf(stderr, \"Invalid sample method, using default: %s\\n\", sd_sample_method_name((sample_method_t)sample_method_found));\n    }\n    sample_method = (sample_method_t)sample_method_found;\n\n    scheduler_t sched = str_to_scheduler(scheduler_str);\n    if (sched != SCHEDULER_COUNT) {\n        scheduler = sched;\n        fprintf(stderr, \"Found scheduler: %s\\n\", scheduler_str);\n    }\n    if (scheduler == SCHEDULER_COUNT) {\n        scheduler = sd_get_default_scheduler(sd_ctx, sample_method);\n        fprintf(stderr, \"Invalid scheduler, using default: %s\\n\", sd_scheduler_name(scheduler));\n    }\n\n    sd_c = sd_ctx;\n\n    return 0;\n}\n","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/go/stablediffusion-ggml/cpp/gosd.cpp#L672-L708","documentation":"Warning during generation setup: the sampler string did not match any sample method in str_to_sample_method(), so sd_get_default_sample_method(sd_ctx) picks the model's default sampler. Generation proceeds; results may differ from the requested sampler (quality/speed characteristics change).","triggerScenarios":"Passing sampler='euler_a'-style names with the wrong spelling/case for this build, or a sampler name introduced in a newer stable-diffusion.cpp than the vendored one.","commonSituations":"API requests or model configs copied from other UIs (A1111/ComfyUI) whose sampler names differ (e.g. 'Euler a' vs 'euler_a'); version drift of sampler enums.","solutions":["Use a sampler name exactly as the vendored str_to_sample_method expects (e.g. euler_a, dpm++2m)","Or omit the sampler to deliberately take the model default","Confirm the fix via the 'Found sampler:' log line"],"exampleFix":"// before\nsampler = \"Euler a\";  // not matched\n\n// after\nsampler = \"euler_a\";","handlingStrategy":"validation","validationCode":"// Go caller: whitelist samplers before the request reaches the backend\nvalidSamplers := map[string]bool{\"euler_a\": true, \"euler\": true, \"heun\": true, \"dpm2\": true, \"dpm++2m\": true, \"lcm\": true}\nif req.Sampler != \"\" && !validSamplers[req.Sampler] {\n    return fmt.Errorf(\"unknown sampler %q\", req.Sampler)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Map names from other UIs (A1111 'Euler a') to the backend's exact enum strings at the API edge","Expose the sampler list from a config endpoint so clients enumerate instead of guessing"],"tags":["stablediffusion","sampler","options","validation"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}