apache/beam · warning
Invalid dictionary call
Error message
Invalid dictionary call
What it means
The specialize tool's dict helper builds a map[string]any from alternating key/value arguments. If an odd number of arguments is passed — meaning some key has no value — it panics with 'Invalid dictionary call'.
Solutions
- Ensure dict() is only ever called with an even number of arguments (key, value pairs)
- Check each dict(...) call site in main.go and count its arguments
- Add a compile-time constant or struct for template params instead of variadic pairs to avoid recurrence
Example fix
// before
dict("namespace", ns, "params")
// after
dict("namespace", ns, "params", params) Defensive patterns
Strategy: validation
Validate before calling
if len(args)%2 != 0 {
return errors.New("dict requires key/value pairs")
} Try / catch
// in the specialize tool
if len(values)%2 != 0 {
return fmt.Errorf("dict called with odd arg count at %s", callerSite)
} Prevention
- Count key/value pairs before calling dict
- Prefer explicit map literals or structs over variadic key/value helpers
When it happens
Trigger: Calling dict() inside the specialize tool's template data construction with an odd number of arguments, e.g. dict("key1", v1, "key2") with a missing value.
Common situations: Editing the specialize tool's generated-code parameters and dropping one of a key/value pair; adding a template variable without its value.
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
- AfterProcessingTime trigger set without a delay or…
- At least one subtrigger required for composite triggers.
- attempted to add namespace to missing coder id
- attempted to add namespace to missing windowing strategy id
- batch: failed to marshal worker UUID
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/9836c5b19e8f7dd0.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/cmd/specialize/main.go:262
var ret []int
for k := 0; k < i; k++ {
ret = append(ret, k)
}
return ret
}
func add(i int, j int) int {
return i + j
}
func mult(i int, j int) int {
return i * j
}
func dict(values ...any) map[string]any {
dict := make(map[string]any, len(values)/2)
if len(values)%2 != 0 {
panic("Invalid dictionary call")
}
for i := 0; i < len(values); i += 2 {
dict[values[i].(string)] = values[i+1]
}
return dict
}
func list(values ...string) []string {
return values
}
func genericTypingRepresentation(in int, out int, includeType bool) string {
seenElements := false
typing := ""
if in > 0 {
typing += fmt.Sprintf("[I%v", 0)
for i := 1; i < in; i++ {View on GitHub (pinned to 12126d8942)