hashicorp/nomad · error
Invalid key value pair for topic: %s
Error message
Invalid key value pair for topic: %s
What it means
This error is returned by the topic/filter parsing helper in `nomad operator debug` when the user-supplied topic spec (a "topic=filter" key/value pair) does not split into the expected 1 or 2 parts. Only formats `topic` and `topic=filter` are accepted; anything with more than one `=` separator (or otherwise malformed input) hits the default case. The topic portion is then title-cased to match the api.Topic enum.
Source
Thrown at command/operator_debug.go:1923
}
return topics, mErrs.ErrorOrNil()
}
func parseTopic(input string) (string, string, error) {
var topic, filter string
parts := strings.Split(input, ":")
switch len(parts) {
case 1:
// infer wildcard if only given a topic
topic = input
filter = "*"
case 2:
topic = parts[0]
filter = parts[1]
default:
return "", "", fmt.Errorf("Invalid key value pair for topic: %s", topic)
}
return cases.Title(language.English).String(topic), filter, nil
}
func allTopics() map[api.Topic][]string {
return map[api.Topic][]string{"*": {"*"}}
}
// topicsFromString parses a comma separated list into a topicMap
func topicsFromString(topicList string) (map[api.Topic][]string, error) {
if topicList == "none" {
return nil, nil
}
if topicList == "all" {
return allTopics(), nil
}
View on GitHub (pinned to 482b49bf1a)
Solutions
- Remove or escape any extra '=' characters so the spec contains at most one '=' (format: topic=filter).
- Use just the topic name with no '=' to apply the default '*' filter.
- Quote the flag value in your shell and verify the variable contents do not contain stray '=' characters.
- Check the topic spelling; it is title-cased (e.g. evaluation, node, deployment) before being matched against api.Topic.
Example fix
// before // -topic="Evaluation=*extra=1" // after // -topic="Evaluation=*"
Defensive patterns
Strategy: validation
Validate before calling
parts := strings.Split(spec, "=")
if len(parts) > 2 {
return fmt.Errorf("topic spec must be 'topic' or 'topic=filter', got %q", spec)
}
topic, filter := parts[0], "*"
if len(parts) == 2 {
filter = parts[1]
} Prevention
- Always build topic specs as 'topic=filter' with a single '='.
- Quote shell flag values to avoid stray '=' from variables.
- Use only known topic names (evaluation, node, deployment, etc.) so the title-cased value matches api.Topic.
When it happens
Trigger: Running `nomad operator debug -topic ...` (or the equivalent API/wrapper call) with a topic string like `a=b=c` or any spec that splits into 3+ parts via strings.Split on '='.
Common situations: Typing an extra '=' in a filter value, pasting a key=value pair containing an encoded '=' (e.g. base64 or URL params) into the filter, or scripting the flag with improperly quoted shell variables containing '='.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- A template must be supplied using '-template' when using go-
- Invalid value for "-out"; valid values are [go-template, hcl
- Error listing host volumes
- -node or -node-pool options can only be used when no ID is p
- Could not find allocation task group: %s
AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04).
Data as JSON: /api/errors/e06c4c4447a516c3.
Report an issue: GitHub.