{"record":{"id":"145d9fc4196cc517","repo":"vitessio/vitess","slug":"s-requires-name-value","errorCode":null,"errorMessage":"--%s requires name=value","messagePattern":"--(.+?) requires name=value","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/schema/ddl_strategy.go","lineNumber":265,"sourceCode":"\t// then be parsed as another statement. A hex literal is parsed safely\n\t// regardless of the active sql_mode.\n\treturn fmt.Sprintf(\"set @@session.%s=X'%x'\", variable.Name, variable.Value), nil\n}\n\n// SessionVariables returns the ordered assignments from repeatable\n// --session-variable name=value options.\nfunc (setting *DDLStrategySetting) SessionVariables() ([]SessionVariable, error) {\n\topts, err := shlex.Split(setting.Options)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid DDL strategy options: %w\", err)\n\t}\n\tvar variables []SessionVariable\n\tfor i := 0; i < len(opts); i++ {\n\t\tif !isFlag(opts[i], sessionVariableFlag) {\n\t\t\tcontinue\n\t\t}\n\t\tif i+1 >= len(opts) {\n\t\t\treturn nil, fmt.Errorf(\"--%s requires name=value\", sessionVariableFlag)\n\t\t}\n\t\ti++\n\t\tname, value, found := strings.Cut(opts[i], \"=\")\n\t\tif !found {\n\t\t\treturn nil, fmt.Errorf(\"invalid --%s value %q: expected name=value\", sessionVariableFlag, opts[i])\n\t\t}\n\t\tvariables = append(variables, SessionVariable{Name: name, Value: value})\n\t}\n\tif err := ValidateSessionVariables(variables); err != nil {\n\t\treturn nil, err\n\t}\n\treturn variables, nil\n}\n\n// IsPostponeLaunch checks if strategy options include --postpone-launch\nfunc (setting *DDLStrategySetting) IsPostponeLaunch() bool {\n\treturn setting.hasFlag(postponeLaunchFlag)\n}","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/schema/ddl_strategy.go#L247-L283","documentation":"SessionVariables() expects each --session-variable flag to be followed by exactly one token of the form name=value. This error is thrown when the flag appears at the end of the token list with no following token at all.","triggerScenarios":"A strategy string ending in the bare flag, e.g. \"online --session-variable\", or where the value got consumed as a separate flag token; detected when i+1 >= len(opts) after matching isFlag(opts[i], sessionVariableFlag).","commonSituations":"Value containing a space without quotes so shlex splits it away; trailing flag left by an empty variable in a template; flag appended last in generated commands with the value dropped by an empty-string filter.","solutions":["Provide the name=value token right after the flag: --session-variable name=value.","Quote values containing spaces so they split as one token.","Check the command/template that builds the strategy string for dropped empty values."],"exampleFix":"// before\nsetting := schema.ParseDDLStrategy(\"online --session-variable\")\n// after\nsetting := schema.ParseDDLStrategy(\"online --session-variable wait_timeout=100\")","handlingStrategy":"validation","validationCode":"if strings.HasSuffix(strings.TrimSpace(options), \"--session-variable\") {\n    // append the name=value token\n}","typeGuard":null,"tryCatchPattern":"if _, err := setting.SessionVariables(); err != nil {\n    return fmt.Errorf(\"bad DDL strategy options: %w\", err)\n}","preventionTips":["Always emit flag and value as a single 'name=value' token pair.","Quote values with spaces so shlex keeps them as one token.","Filter out empty values before appending flags in generated commands."],"tags":["ddl","parsing","cli-flags"],"backgroundTag":"missing-flag-argument","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}