{"record":{"id":"b6c6c656c1e10ce4","repo":"dagger/dagger","slug":"arrayinput-new-d-w","errorCode":null,"errorMessage":"ArrayInput.New[%d]: %w","messagePattern":"ArrayInput\\.New\\[(.+?)\\]: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dagql/types.go","lineNumber":1356,"sourceCode":"\tfor i, val := range a {\n\t\tvalues[i] = val\n\t}\n\treturn values\n}\n\nvar _ InputDecoder = ArrayInput[Input]{}\n\nfunc (a ArrayInput[I]) DecodeInput(val any) (Input, error) {\n\tswitch x := val.(type) {\n\tcase []any:\n\t\tvar zero I\n\t\tdecoder := zero.Decoder()\n\n\t\tarr := make(ArrayInput[I], len(x))\n\t\tfor i, val := range x {\n\t\t\telem, err := decoder.DecodeInput(val)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"ArrayInput.New[%d]: %w\", i, err)\n\t\t\t}\n\t\t\tarr[i] = elem.(I) // TODO sus\n\t\t}\n\t\treturn arr, nil\n\tcase string: // default\n\t\tvar vals []any\n\t\tdec := json.NewDecoder(strings.NewReader(x))\n\t\tdec.UseNumber()\n\t\tif err := dec.Decode(&vals); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"decode %q: %w\", x, err)\n\t\t}\n\t\treturn a.DecodeInput(vals)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"cannot create ArrayInput from %T\", x)\n\t}\n}\n\nfunc (i ArrayInput[S]) ToLiteral() call.Literal {","sourceCodeStart":1338,"sourceCodeEnd":1374,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/dagql/types.go#L1338-L1374","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\narr, err := dagql.ArrayInput[dagql.String]{}.New([]any{123}) // int, decoder wants string\n// after\narr, err := dagql.ArrayInput[dagql.String]{}.New([]any{\"123\"})","handlingStrategy":"validation","validationCode":"for i, v := range x {\n    if v == nil { return fmt.Errorf(\"element %d is nil\", i) }\n}","typeGuard":null,"tryCatchPattern":"arr, err := dagql.ArrayInput[I]{}.New(x)\nif err != nil {\n    return fmt.Errorf(\"bad array input (fix element per reported index): %w\", err)\n}","preventionTips":["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."],"tags":["dagql","array","decode-input","input-validation"],"backgroundTag":"array-element-decode-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}