{"record":{"id":"b06a93bc28cb80ea","repo":"vitessio/vitess","slug":"w-at-least-the-js-flag-is-required-in-the-valu","errorCode":null,"errorMessage":"%w: at least the --js flag is required in the value of the flag --mysql-shell-flags","messagePattern":"%w: at least the --js flag is required in the value of the flag --mysql-shell-flags","errorType":"error_code","errorClass":"ErrMySQLShellPreCheck","httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/mysqlshellbackupengine.go","lineNumber":484,"sourceCode":"// mysqlShellBackupLocation with the provided directory and name components.\n// For local filesystem mode, it uses fileutil.SafePathJoin to prevent path\n// traversal outside the configured backup location. For object storage,\n// path.Join is used since SafePathJoin relies on OS-native path operations\n// that don't understand cloud URIs.\nfunc (be *MySQLShellBackupEngine) backupLocation(dir, name string) (string, error) {\n\tif isObjectStoreFlags(mysqlShellDumpFlags) {\n\t\treturn path.Join(mysqlShellBackupLocation, dir, name), nil\n\t}\n\treturn fileutil.SafePathJoin(mysqlShellBackupLocation, dir, name)\n}\n\nfunc (be *MySQLShellBackupEngine) backupPreCheck(location string) error {\n\tif mysqlShellBackupLocation == \"\" {\n\t\treturn fmt.Errorf(\"%w: no backup location set via --mysql-shell-backup-location\", ErrMySQLShellPreCheck)\n\t}\n\n\tif mysqlShellFlags == \"\" || !strings.Contains(mysqlShellFlags, \"--js\") {\n\t\treturn fmt.Errorf(\"%w: at least the --js flag is required in the value of the flag --mysql-shell-flags\", ErrMySQLShellPreCheck)\n\t}\n\n\t// make sure the target directory exists if the target location for the backup is not an object store\n\t// (e.g. is the local filesystem) as MySQL Shell doesn't create the entire path beforehand:\n\tif !isObjectStoreFlags(mysqlShellDumpFlags) {\n\t\terr := os.MkdirAll(location, 0o750)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failure creating directory %s: %w\", location, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (be *MySQLShellBackupEngine) restorePreCheck(ctx context.Context, params RestoreParams) (shouldDeleteUsers bool, err error) {\n\tif mysqlShellFlags == \"\" {\n\t\treturn shouldDeleteUsers, fmt.Errorf(\"%w: at least the --js flag is required in the value of the flag --mysql-shell-flags\", ErrMySQLShellPreCheck)\n\t}","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqlshellbackupengine.go#L466-L502","documentation":"The MySQL Shell engine drives dumps via JS mode, so the --mysql-shell-flags value must contain at least the --js flag. backupPreCheck() wraps ErrMySQLShellPreCheck with this message when mysqlShellFlags is empty or lacks \"--js\". Backup aborts before the dump starts.","triggerScenarios":"Calling MySQLShellBackupEngine.ExecuteBackup when mysqlShellFlags is \"\" or its value does not contain the substring --js (e.g. flags set to only --defaults-file=...).","commonSituations":"Operators copy flag strings from MySQL Shell docs that omit --js; --mysql-shell-flags left at default empty value; typos like \"-js\" or \"--javascript\".","solutions":["Set --mysql-shell-flags to include --js, e.g. --mysql-shell-flags \"--js --defaults-file=/etc/my.cnf\".","Verify the value contains the literal \"--js\" (grep the process args).","Keep any extra util flags (like --defaults-extra-file) alongside --js rather than replacing it."],"exampleFix":"// before: missing --js\n--mysql-shell-flags \"--defaults-file=/etc/my.cnf\"\n// after\n--mysql-shell-flags \"--js --defaults-file=/etc/my.cnf\"","handlingStrategy":"validation","validationCode":"if !strings.Contains(mysqlShellFlags, \"--js\") {\n\treturn errors.New(\"--mysql-shell-flags must contain at least --js\")\n}","typeGuard":null,"tryCatchPattern":"err := engine.ExecuteBackup(ctx, backupParams)\nif errors.Is(err, mysqlctl.ErrMySQLShellPreCheck) {\n\t// inspect message: missing --js means flag misconfiguration; fix config and restart\n\treturn err\n}","preventionTips":["Never construct --mysql-shell-flags without --js; use a shared constant or template.","Validate flags in startup scripts before launching vttablet/vtbackup.","Beware lookalikes: only the literal \"--js\" passes the check."],"tags":["backup","mysqlshell","configuration","invalid-flag"],"backgroundTag":"missing-flag","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}