{"record":{"id":"01e1036600f87a77","repo":"mudler/LocalAI","slug":"ds4-worker-missing-value-for-s","errorCode":null,"errorMessage":"ds4-worker: missing value for %s\n","messagePattern":"ds4-worker: missing value for (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/cpp/ds4/worker_main.c","lineNumber":25,"sourceCode":"// only needs the engine objects + ds4_distributed.o, which the backend already\n// builds. It is launched by `local-ai worker ds4-distributed`.\n//\n// Usage:\n//   ds4-worker --role worker --model <gguf> --layers 20:output \\\n//              --coordinator <host> <port> [--cpu|--cuda|--metal] [-c CTX] [-t N]\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <signal.h>\n#include <limits.h>\n\n#include \"ds4.h\"\n#include \"ds4_distributed.h\"\n\nstatic const char *need_arg(int *i, int argc, char **argv, const char *flag) {\n    if (*i + 1 >= argc) {\n        fprintf(stderr, \"ds4-worker: missing value for %s\\n\", flag);\n        exit(2);\n    }\n    return argv[++(*i)];\n}\n\nstatic int parse_int_arg(const char *s, const char *flag) {\n    char *end = NULL;\n    long v = strtol(s, &end, 10);\n    if (!s[0] || *end || v <= 0 || v > INT_MAX) {\n        fprintf(stderr, \"ds4-worker: invalid value for %s: %s\\n\", flag, s);\n        exit(2);\n    }\n    return (int)v;\n}\n\nstatic ds4_backend default_backend(void) {\n#if defined(DS4_NO_GPU)\n    return DS4_BACKEND_CPU;","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/cpp/ds4/worker_main.c#L7-L43","documentation":"CLI usage error from the ds4 distributed worker binary: need_arg() reached a flag that requires a value (-m/--model, -c/--ctx, -t/--threads, or a distributed flag) as the last argv element, so there is no following token to consume. The worker exits with status 2 immediately — before any model or network work.","triggerScenarios":"Invoking ds4-worker with a trailing flag and no value, e.g. 'ds4-worker --role worker -m' or '... --layers 8 --ctx' — need_arg sees *i+1 >= argc, prints the flag name, exit(2).","commonSituations":"Hand-written launcher scripts or Kubernetes container args truncating the arg list; shell quoting mistakes that swallow a value; copy-pasting a command and deleting the last value; templating engines (Helm) emitting an empty value that collapses to nothing.","solutions":["Re-run with the value appended: every flag printed in the message needs an argument (-m PATH, -c N, -t N, --role worker).","Add a usage guard in launcher scripts: validate arg pairs with a wrapper (e.g. while [ $# -gt 0 ] case ... esac requiring $2) or run 'ds4-worker --help' to see the exact grammar.","Check Helm/docker templating: ensure values are non-empty and not rendered as bare flags when empty."],"exampleFix":"# before\nds4-worker --role worker --layers 8 -m\n\n# after\nds4-worker --role worker --layers 8 -m /models/ds4.gguf","handlingStrategy":"validation","validationCode":"# bash launcher: reject trailing valueless flags before exec\nfor a in \"$@\"; do case \"$a\" in -m|--model|-c|--ctx|-t|--threads|--role|--layers)\n  [ \"${LAST:-}\" = \"$a\" ] && { echo \"missing value for $a\" >&2; exit 2; };; esac; LAST=\"$a\"; done\nexec ds4-worker \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build argv arrays as (flag, value) pairs in scripts so a missing value is a visible empty slot.","Run ds4-worker --help when onboarding a new launcher to lock in which flags take values.","In Helm charts, render flags conditionally so empty values omit the flag entirely."],"tags":["c","ds4","cli","usage-error","distributed"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}