dagger/dagger · error
ArrayInput.New[%d]: %w
Error message
ArrayInput.New[%d]: %w
What it means
ArrayInput.New builds an ArrayInput[I] from raw input values by decoding each element with the type's Decoder. If decoding element i fails, this error wraps the decoder error with the index. It surfaces during input construction from GraphQL variables or programmatic literal values.
Source
Thrown at dagql/types.go:1356
for i, val := range a {
values[i] = val
}
return values
}
var _ InputDecoder = ArrayInput[Input]{}
func (a ArrayInput[I]) DecodeInput(val any) (Input, error) {
switch x := val.(type) {
case []any:
var zero I
decoder := zero.Decoder()
arr := make(ArrayInput[I], len(x))
for i, val := range x {
elem, err := decoder.DecodeInput(val)
if err != nil {
return nil, fmt.Errorf("ArrayInput.New[%d]: %w", i, err)
}
arr[i] = elem.(I) // TODO sus
}
return arr, nil
case string: // default
var vals []any
dec := json.NewDecoder(strings.NewReader(x))
dec.UseNumber()
if err := dec.Decode(&vals); err != nil {
return nil, fmt.Errorf("decode %q: %w", x, err)
}
return a.DecodeInput(vals)
default:
return nil, fmt.Errorf("cannot create ArrayInput from %T", x)
}
}
func (i ArrayInput[S]) ToLiteral() call.Literal {View on GitHub (pinned to 82ba2681db)
Solutions
- Check the element at the reported index and conform it to the expected input type of I.
- Validate the array before calling New (all elements same JSON shape as I's decoder expects).
- If I has a custom DecodeInput, test it in isolation for the failing value.
- For strings, remember New falls back to JSON-decoding the whole string — ensure it is a JSON array, not a bare list.
Example fix
// before
arr, err := dagql.ArrayInput[dagql.String]{}.New([]any{123}) // int, decoder wants string
// after
arr, err := dagql.ArrayInput[dagql.String]{}.New([]any{"123"}) Defensive patterns
Strategy: validation
Validate before calling
for i, v := range x {
if v == nil { return fmt.Errorf("element %d is nil", i) }
} Try / catch
arr, err := dagql.ArrayInput[I]{}.New(x)
if err != nil {
return fmt.Errorf("bad array input (fix element per reported index): %w", err)
} Prevention
- Match every element's shape to element type I's decoder expectations.
- Pass []any or JSON-array strings, not arbitrary Go values.
- Unit-test custom Input DecodeInput implementations with representative values.
When it happens
Trigger: Calling ArrayInput[I].New with a slice x containing a value that element type I cannot DecodeInput — wrong JSON type per element (string where object expected), an element failing its custom Decoder, or nested literal shape mismatch.
Common situations: SDK/CLI code constructing inputs programmatically with elements of the wrong shape; GraphQL variables where one array item violates the input type schema; custom Input types with buggy DecodeInput implementations.
Related errors
- index %d out of bounds
- index %d from %T without call frame
- slice elem val %d: %w
- nil ID input
- map array[%d]: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/b6c6c656c1e10ce4.
Report an issue: GitHub.