{"record":{"id":"9cae85de344e0638","repo":"dagger/dagger","slug":"argument-q-must-be-of-type-directory-to-apply-ign","errorCode":null,"errorMessage":"argument %q must be of type Directory to apply ignore pattern ([%s]) but type is %#v","messagePattern":"argument %q must be of type Directory to apply ignore pattern \\(\\[(.+?)\\]\\) but type is %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/modfunc.go","lineNumber":1377,"sourceCode":"\tcase dagql.DynamicOptional:\n\t\tif !value.Valid {\n\t\t\treturn nil, nil\n\t\t}\n\t\tswitch id := value.Value.(type) {\n\t\tcase dagql.AnyID:\n\t\t\treturn applyIgnore(id)\n\t\tcase dagql.ID[*Directory]:\n\t\t\treturn applyIgnore(id)\n\t\tcase dagql.IDType:\n\t\t\tif dirid, ok := id.(dagql.ID[*Directory]); ok {\n\t\t\t\treturn applyIgnore(dirid)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"not a directory id: %#v\", id)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"not a directory id: %#v\", value.Value)\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"argument %q must be of type Directory to apply ignore pattern ([%s]) but type is %#v\", arg.OriginalName, strings.Join(arg.Ignore, \", \"), value)\n\t}\n}\n\n// jsonListElements parses a JSON array default value into its elements. TOML\n// array settings arrive JSON-encoded (see configValueToString); ok is false\n// for plain strings, which callers split on commas instead.\nfunc jsonListElements(userInput string) ([]any, bool) {\n\ttrimmed := strings.TrimSpace(userInput)\n\tif !strings.HasPrefix(trimmed, \"[\") {\n\t\treturn nil, false\n\t}\n\tvar list []any\n\tif err := json.Unmarshal([]byte(trimmed), &list); err != nil {\n\t\treturn nil, false\n\t}\n\treturn list, true\n}\n","sourceCodeStart":1359,"sourceCodeEnd":1395,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/modfunc.go#L1359-L1395","documentation":"The final fallback: the argument's resolved runtime value has a type entirely outside the shapes applyIgnoreOnDir understands, so ignore patterns cannot be applied. The message names the argument, its ignore patterns, and the offending Go value. It means \"you asked for ignore on this argument, but what was passed is not anything Directory-ID-shaped\".","triggerScenarios":"An argument with ignore patterns receives a value of an unhandled Go type at the default switch arm — e.g. a JSON-decoded value, a *Directory instance object, or an array/map — instead of a typed dagql ID or optional-wrapped ID.","commonSituations":"Custom integrations invoking module functions with hand-marshaled JSON args; SDK version mismatch where the argument decoder emits new wrapper types applyIgnoreOnDir does not know; mistakenly putting ignore on a list-of-Directories argument.","solutions":["Ensure the argument is a single Directory and the value passed is its typed ID (or optional-wrapped ID).","Remove ignore from non-Directory (e.g. list) arguments; apply excludes when constructing each Directory instead.","Align SDK, CLI, and engine versions and regenerate the module SDK to restore the expected value shapes."],"exampleFix":"// before: ignore on a list argument\nsrcs []*Directory `ignore:\"[\\\".git\\\"]\"` // unsupported shape\n// after: single Directory argument, exclude applied at construction\nsrc *Directory // ignore valid; or client.Directory().WithExclude([\".git\"]) per element","handlingStrategy":"validation","validationCode":"// confirm the argument is a single Directory before enabling ignore\nif arg.TypeDef.Kind == ListTypeDefKind || !isDirectoryArg(arg.TypeDef) {\n    return fmt.Errorf(\"ignore patterns are only supported on a single Directory argument\")\n}","typeGuard":"func valueIsDirectoryShaped(v any) bool {\n    switch t := v.(type) {\n    case dagql.ID[*Directory]: return true\n    case dagql.DynamicOptional: return t.Valid && isTypedID(t.Value)\n    default: return false\n    }\n}","tryCatchPattern":null,"preventionTips":["Attach ignore only to single Directory parameters, never lists or other objects.","Keep CLI, SDK, and engine on matching versions so decoder output shapes match.","Marshal module call arguments through the SDK, not hand-written JSON."],"tags":["dagger","type-guard","ignore-pattern"],"backgroundTag":"ignore-pattern-on-non-directory-argument","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"}