vitessio/vitess · error
action requires only one of %v or %v-file
Error message
action requires only one of %v or %v-file
What it means
getFileParam resolves a value that may be supplied either inline via a flag or via a file flag. If BOTH the inline flag and the -file flag are set, it refuses with this error since only one source is allowed.
Source
Thrown at go/vt/vtctl/vtctl.go:814
keyspace = "<null>"
}
if shard == "" {
shard = "<null>"
}
mtst := "<null>"
// 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 matchingView on GitHub (pinned to 01a25a7d17)
Solutions
- Remove either the inline flag or the -file flag so exactly one is provided.
- If automation sets both, prefer the -file flag and blank the inline one (or vice versa).
- Audit the wrapper script for unconditional flag defaults that collide with user-supplied file flags.
Example fix
// before ApplySchema --sql "ALTER TABLE t ADD COLUMN c INT" --sql-file schema.sql commerce // after ApplySchema --sql-file schema.sql commerce
Defensive patterns
Strategy: validation
Validate before calling
if sqlFlag && sqlFileFlag {
panic("ApplySchema: provide only one of --sql or --sql-file")
} Type guard
null
Try / catch
try {
run("vtctlclient ApplySchema --sql ... --sql-file ... commerce")
} catch (e) {
if (String(e).includes("requires only one of")) {
console.error("Drop either the inline flag or the -file flag and retry")
} else throw e
} Prevention
- In wrapper scripts, emit at most one of the inline and -file flags.
- Validate flag combinations before exec'ing vtctlclient.
- Make file-based input the single canonical path in CI pipelines.
When it happens
Trigger: Calling ApplySchema (or similar commands using getFileParam, e.g. for the `sql` parameter) with both e.g. `--sql "..."` and `--sql-file schema.sql` set at the same time.
Common situations: Script/template assembling a command line where the inline value is a default and a file path was appended; combining legacy and new flags in automation; copy-pasted command lines accumulating flags.
Understand the failure class
Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.
Related errors
- action requires one of %v or %v-file
- --enable and --disable are mutually exclusive
- cannot read file %v: %v
- the <cell> argument is required for the UpdateCellInfo comma
- the <cell> argument is required for the DeleteCellInfo comma
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/36cc78a0640708db.
Report an issue: GitHub.