{"record":{"id":"9bfde4a9648e310d","repo":"vitessio/vitess","slug":"action-requires-one-of-v-or-v-file","errorCode":null,"errorMessage":"action requires one of %v or %v-file","messagePattern":"action requires one of (.+?) or (.+?)-file","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/vtctl.go","lineNumber":820,"sourceCode":"\t// special case for old primary that hasn't updated topo yet\n\tif ti.PrimaryTermStartTime != nil && ti.PrimaryTermStartTime.Seconds > 0 {\n\t\tmtst = protoutil.TimeFromProto(ti.PrimaryTermStartTime).UTC().Format(time.RFC3339)\n\t}\n\treturn fmt.Sprintf(\"%v %v %v %v %v %v %v %v\", topoproto.TabletAliasString(ti.Alias), keyspace, shard, topoproto.TabletTypeLString(ti.Type), ti.Addr(), ti.MysqlAddr(), fmtMapAwkable(ti.Tags), mtst)\n}\n\n// getFileParam returns a string containing either flag is not \"\",\n// or the content of the file named flagFile\nfunc getFileParam(flag, flagFile, name string) (string, error) {\n\tif flag != \"\" {\n\t\tif flagFile != \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"action requires only one of %v or %v-file\", name, name)\n\t\t}\n\t\treturn flag, nil\n\t}\n\n\tif flagFile == \"\" {\n\t\treturn \"\", fmt.Errorf(\"action requires one of %v or %v-file\", name, name)\n\t}\n\tdata, err := os.ReadFile(flagFile)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"cannot read file %v: %v\", flagFile, err)\n\t}\n\treturn string(data), nil\n}\n\n// keyspaceParamsToKeyspaces builds a list of keyspaces.\n// It supports topology-based wildcards, and plain wildcards.\n// For instance:\n// us*                             // using plain matching\n// *                               // using plain matching\nfunc keyspaceParamsToKeyspaces(ctx context.Context, wr *wrangler.Wrangler, params []string) ([]string, error) {\n\tresult := make([]string, 0, len(params))\n\tfor _, param := range params {\n\t\tif len(param) == 0 {\n\t\t\treturn nil, errors.New(\"empty keyspace param in list\")","sourceCodeStart":802,"sourceCodeEnd":838,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/vtctl.go#L802-L838","documentation":"getFileParam requires at least one source for the named parameter: either the inline flag or the -file flag. If the inline flag is empty AND the -file flag is empty, it returns this error indicating neither was provided.","triggerScenarios":"Running ApplySchema (or any command using getFileParam) without providing e.g. `--sql` or `--sql-file` — the value parameter is entirely missing from the command line.","commonSituations":"Forgetting the SQL argument when running ApplySchema interactively; a script variable that is empty causing the flag to be dropped; wrong flag name typo so the intended flag isn't recognized as either parameter.","solutions":["Provide the value inline (e.g. `--sql \"...\"`) or via file (e.g. `--sql-file schema.sql`).","Check that the script variable holding the SQL is non-empty before invoking.","Verify flag spelling matches what the command registers (e.g. `--sql-file`, not `--sqlfile`)."],"exampleFix":"// before\nApplySchema commerce   // no --sql / --sql-file\n// after\nApplySchema --sql-file schema.sql commerce","handlingStrategy":"validation","validationCode":"if (!sqlFlag && !sqlFileFlag) {\n  throw new Error(\"ApplySchema requires --sql or --sql-file\")\n}","typeGuard":"null","tryCatchPattern":"try {\n  run(\"vtctlclient ApplySchema commerce\")\n} catch (e) {\n  if (String(e).includes(\"requires one of\")) {\n    console.error(\"Supply --sql '<statements>' or --sql-file <path>\")\n  } else throw e\n}","preventionTips":["Fail fast in scripts when the SQL variable is empty before invoking vtctlclient.","Double-check flag spellings: `--sql` and `--sql-file`.","Keep schema DDL in files and always pass --sql-file."],"tags":["cli","flag-validation","apply-schema","missing-argument"],"backgroundTag":"missing-required-flag","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}