mudler/LocalAI · error

ds4-worker: missing value for %s

Error message

ds4-worker: missing value for %s

What it means

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.

Source

Thrown at backend/cpp/ds4/worker_main.c:25

// only needs the engine objects + ds4_distributed.o, which the backend already
// builds. It is launched by `local-ai worker ds4-distributed`.
//
// Usage:
//   ds4-worker --role worker --model <gguf> --layers 20:output \
//              --coordinator <host> <port> [--cpu|--cuda|--metal] [-c CTX] [-t N]

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <limits.h>

#include "ds4.h"
#include "ds4_distributed.h"

static const char *need_arg(int *i, int argc, char **argv, const char *flag) {
    if (*i + 1 >= argc) {
        fprintf(stderr, "ds4-worker: missing value for %s\n", flag);
        exit(2);
    }
    return argv[++(*i)];
}

static int parse_int_arg(const char *s, const char *flag) {
    char *end = NULL;
    long v = strtol(s, &end, 10);
    if (!s[0] || *end || v <= 0 || v > INT_MAX) {
        fprintf(stderr, "ds4-worker: invalid value for %s: %s\n", flag, s);
        exit(2);
    }
    return (int)v;
}

static ds4_backend default_backend(void) {
#if defined(DS4_NO_GPU)
    return DS4_BACKEND_CPU;

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Re-run with the value appended: every flag printed in the message needs an argument (-m PATH, -c N, -t N, --role worker).
  2. 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.
  3. Check Helm/docker templating: ensure values are non-empty and not rendered as bare flags when empty.

Example fix

# before
ds4-worker --role worker --layers 8 -m

# after
ds4-worker --role worker --layers 8 -m /models/ds4.gguf
Defensive patterns

Strategy: validation

Validate before calling

# bash launcher: reject trailing valueless flags before exec
for a in "$@"; do case "$a" in -m|--model|-c|--ctx|-t|--threads|--role|--layers)
  [ "${LAST:-}" = "$a" ] && { echo "missing value for $a" >&2; exit 2; };; esac; LAST="$a"; done
exec ds4-worker "$@"

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/01e1036600f87a77. Report an issue: GitHub.