vitessio/vitess · error
action requires one of %v or %v-file
Error message
action requires one of %v or %v-file
What it means
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.
Source
Thrown at go/vt/vtctl/vtctl.go:820
// special case for old primary that hasn't updated topo yet
if ti.PrimaryTermStartTime != nil && ti.PrimaryTermStartTime.Seconds > 0 {
mtst = protoutil.TimeFromProto(ti.PrimaryTermStartTime).UTC().Format(time.RFC3339)
}
return 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)
}
// getFileParam returns a string containing either flag is not "",
// or the content of the file named flagFile
func getFileParam(flag, flagFile, name string) (string, error) {
if flag != "" {
if flagFile != "" {
return "", fmt.Errorf("action requires only one of %v or %v-file", name, name)
}
return flag, nil
}
if flagFile == "" {
return "", fmt.Errorf("action requires one of %v or %v-file", name, name)
}
data, err := os.ReadFile(flagFile)
if err != nil {
return "", fmt.Errorf("cannot read file %v: %v", flagFile, err)
}
return string(data), nil
}
// keyspaceParamsToKeyspaces builds a list of keyspaces.
// It supports topology-based wildcards, and plain wildcards.
// For instance:
// us* // using plain matching
// * // using plain matching
func keyspaceParamsToKeyspaces(ctx context.Context, wr *wrangler.Wrangler, params []string) ([]string, error) {
result := make([]string, 0, len(params))
for _, param := range params {
if len(param) == 0 {
return nil, errors.New("empty keyspace param in list")View on GitHub (pinned to 01a25a7d17)
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`).
Example fix
// before ApplySchema commerce // no --sql / --sql-file // after ApplySchema --sql-file schema.sql commerce
Defensive patterns
Strategy: validation
Validate before calling
if (!sqlFlag && !sqlFileFlag) {
throw new Error("ApplySchema requires --sql or --sql-file")
} Type guard
null
Try / catch
try {
run("vtctlclient ApplySchema commerce")
} catch (e) {
if (String(e).includes("requires one of")) {
console.error("Supply --sql '<statements>' or --sql-file <path>")
} else throw e
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- action requires only one of %v or %v-file
- the <tablet alias> argument is required for the SetReadWrite
- action StartReplication requires <tablet alias>
- action StopReplication requires <tablet alias>
- the <tablet alias> and <db type> arguments are required for
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/9bfde4a9648e310d.
Report an issue: GitHub.