mudler/LocalAI · error
ds4-worker: invalid value for %s: %s
Error message
ds4-worker: invalid value for %s: %s
What it means
CLI validation in the ds4 worker's parse_int_arg(): the value string for a numeric flag (-c/--ctx, -t/--threads, or a distributed numeric option) is rejected when it is empty, contains non-digit trailing characters, or parses to a value <= 0 or > INT_MAX. The worker exits with status 2 before touching the model.
Source
Thrown at backend/cpp/ds4/worker_main.c:35
#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;
#elif defined(__APPLE__)
return DS4_BACKEND_METAL;
#else
return DS4_BACKEND_CUDA;
#endif
}
int main(int argc, char **argv) {
signal(SIGPIPE, SIG_IGN);
View on GitHub (pinned to 44413a9d06)
Solutions
- Supply a plain positive decimal integer within int range: '--ctx 32768', '--threads 8'.
- Strip units in generating scripts: use $(( ... )) arithmetic or 'numfmt --from=iec' to precompute the raw number.
- Echo the assembled command line in your launcher before exec so a bad substitution is visible.
Example fix
# before ds4-worker --role worker -m model.gguf --ctx 8k -t 0 # after ds4-worker --role worker -m model.gguf --ctx 8192 -t 8
Defensive patterns
Strategy: validation
Validate before calling
# bash: pre-validate every numeric arg
is_pos_int() { case "$1" in ''|*[!0-9]*) return 1;; esac; [ "$1" -gt 0 ] && [ "$1" -le 2147483647 ]; }
for v in "$CTX" "$THREADS"; do is_pos_int "$v" || { echo "bad numeric value: $v" >&2; exit 2; }; done Type guard
bool valid_ds4_int(const char *s) {
char *end; long v = strtol(s, &end, 10);
return s[0] && !*end && v > 0 && v <= INT_MAX;
} Prevention
- Never pass suffixed quantities ('8k', '1M') to ds4 numeric flags; precompute raw integers.
- Fail fast in launchers on empty env vars instead of letting them reach argv.
- Remember ctx must be > 0 and fit in int; extremely large values are rejected even if numerically valid.
When it happens
Trigger: Passing 'ds4-worker -c 0', '-c -1', '-c 32k', '-t abc', or a value above 2147483647; strtol sets end and the check !s[0] || *end || v <= 0 || v > INT_MAX fires.
Common situations: Using KB/MB-style suffixes ('--ctx 8k') where a plain integer is required; environment variables expanding to empty strings; negative or zero values from miscomputed scripts; 64-bit counts overflowing INT_MAX.
Related errors
- ds4-worker: missing value for %s
- ds4-worker: %s
- ds4-worker: unknown option: %s
- ds4-worker: --role worker is required
- ds4-worker: --model is required
AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15).
Data as JSON: /api/errors/2dfc8f07d7604fde.
Report an issue: GitHub.