{"record":{"id":"eb6fe0fbe69d41aa","repo":"AdguardTeam/AdGuardHome","slug":"got-s-without-argument","errorCode":null,"errorMessage":"got %s without argument","messagePattern":"got (.+?) without argument","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/home/options.go","lineNumber":453,"sourceCode":"\tif err != nil {\n\t\treturn o, eff, fmt.Errorf(\"applying option %s: %w\", arg, err)\n\t}\n\n\treturn newOpts, newEff, nil\n}\n\n// applyOptWithValue applies argument with value.   next and eff must not\n// be nil.\nfunc applyOptWithValue(\n\topt cmdLineOpt,\n\tnext func() (int, string, bool),\n\to options,\n\teff effect,\n\targ string,\n) (newOpt options, newEff effect, err error) {\n\t_, val, ok := next()\n\tif !ok {\n\t\treturn o, eff, fmt.Errorf(\"got %s without argument\", arg)\n\t}\n\n\tnewOpts, err := opt.updateWithValue(o, val)\n\tif err != nil {\n\t\treturn o, eff, fmt.Errorf(\"applying option %s: %w\", arg, err)\n\t}\n\n\treturn newOpts, eff, nil\n}\n\n// findMatchingOpt returns cmdLineOpt which matches the given arg.  ok indicates\n// whether the appropriate option was found.\nfunc findMatchingOpt(arg string) (opt cmdLineOpt, ok bool) {\n\tfor _, opt := range cmdLineOpts {\n\t\tif argMatches(opt, arg) {\n\t\t\treturn opt, true\n\t\t}\n\t}","sourceCodeStart":435,"sourceCodeEnd":471,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/options.go#L435-L471","documentation":"A command-line option that requires a value was the last token on the command line, so the iterator next() returned no value. applyOptWithValue reports which flag is missing its argument.","triggerScenarios":"Ending argv with a value-taking flag: ./AdGuardHome -c or ./AdGuardHome --workdir with nothing after it.","commonSituations":"Shell scripts where a variable expands to empty (-w \"$WORKDIR\" with WORKDIR unset), or truncated command lines in service unit files.","solutions":["Append the required value after the flag: -c /path/to/config.yaml","Quote and default empty shell variables: -w \"${WORKDIR:-/var/lib/adguardhome}\"","Validate generated command lines in scripts before executing"],"exampleFix":"# before\n./AdGuardHome -c\n\n# after\n./AdGuardHome -c /etc/adguardhome.yaml","handlingStrategy":"validation","validationCode":"// Ensure value-taking flags are never last:\nif strings.HasPrefix(arg, \"-\") && i == len(args)-1 && requiresValue(arg) {\n    return fmt.Errorf(\"flag %s needs a value\", arg)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default empty shell variables: ${CFG:-/etc/adguardhome.yaml}\nQuote variables in service units and scripts"],"tags":["go","cli","argument-parsing","missing-value"],"backgroundTag":"missing-cli-option-value","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}