{"record":{"id":"85bca744ee525252","repo":"vitessio/vitess","slug":"invalid-ddl-strategy-options-w","errorCode":null,"errorMessage":"invalid DDL strategy options: %w","messagePattern":"invalid DDL strategy options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/schema/ddl_strategy.go","lineNumber":257,"sourceCode":"func (variable SessionVariable) SetStatement() (string, error) {\n\tif err := ValidateSessionVariable(variable); err != nil {\n\t\treturn \"\", err\n\t}\n\t// A connection default or an earlier assignment may enable\n\t// NO_BACKSLASH_ESCAPES.\n\t// In that mode, encoding O'Reilly as 'O\\'Reilly' closes the string after\n\t// the backslash; on a multi-statement DBA connection, a crafted suffix could\n\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","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/schema/ddl_strategy.go#L239-L275","documentation":"DDLStrategySetting.SessionVariables() tokenizes the strategy's Options string with shlex.Split; this error wraps a shell-lexing failure. It means the options text is unparseable, typically due to unbalanced or malformed quoting, and no session variables can be extracted.","triggerScenarios":"A --ddl-strategy value whose trailing options contain unbalanced quotes, e.g. \"online --session-variable foo='bar\" (unterminated single quote), passed through ParseDDLStrategy.","commonSituations":"Quoting mangled by shell layers or CI YAML templating; values containing spaces or quotes pasted without escaping; differing quoting conventions between local shell and container exec.","solutions":["Fix the quoting in the strategy options so shlex can split them (balance all quotes).","Test the options string with shlex.Split directly to see the underlying parse error.","Simplify: avoid quotes in values or use escaped forms shlex accepts."],"exampleFix":"// before\nsetting := schema.ParseDDLStrategy(\"online --session-variable foo='bar\")\n// after\nsetting := schema.ParseDDLStrategy(\"online --session-variable foo=bar\")","handlingStrategy":"validation","validationCode":"if _, err := shlex.Split(options); err != nil {\n    // fix quoting before passing to ParseDDLStrategy\n}","typeGuard":null,"tryCatchPattern":"setting := schema.ParseDDLStrategy(strategyStr)\nif setting.SessionVariables == nil { /* parse path surfaced the error */ }","preventionTips":["Quote values containing spaces or quotes; balance all quotes.","Test strategy strings through the exact shell layers that will run them.","Avoid embedding user text into strategy options unescaped."],"tags":["ddl","parsing","quoting"],"backgroundTag":"invalid-option-syntax","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}