{"record":{"id":"7863c2c299bbee40","repo":"dagger/dagger","slug":"unknown-git-contextual-argument-type-q","errorCode":null,"errorMessage":"unknown git contextual argument type %q","messagePattern":"unknown git contextual argument type %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/modfunc.go","lineNumber":1209,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"get contextual git repository ID: %w\", err)\n\t\t}\n\t\treturn dagql.NewID[*GitRepository](gitID), nil\n\tcase \"GitRef\":\n\t\tvar gitRef dagql.ObjectResult[*GitRef]\n\t\terr := dag.Select(ctx, git, &gitRef,\n\t\t\tdagql.Selector{Field: \"head\"},\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"load contextual git ref: %w\", err)\n\t\t}\n\t\tgitRefID, err := gitRef.ID()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"get contextual git ref ID: %w\", err)\n\t\t}\n\t\treturn dagql.NewID[*GitRef](gitRefID), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unknown git contextual argument type %q\", arg.TypeDef.Self().AsObject.Value.Self().Name)\n\t}\n}\n\n// callerInModuleFunction reports whether ctx is executing inside a module\n// function body. It keys off an active function call, not merely a module in\n// context: a direct client (CLI/SDK) and schema-walking flows like `dagger\n// generate` load a module but run no function, and must still be allowed to\n// auto-inject a Workspace. ErrNoCurrentModule is the direct-client signal and is\n// swallowed; any other error is a real lookup failure.\nfunc callerInModuleFunction(ctx context.Context) (bool, error) {\n\tquery, err := CurrentQuery(ctx)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"get current query: %w\", err)\n\t}\n\tfnCall, err := query.CurrentFunctionCall(ctx)\n\tif errors.Is(err, ErrNoCurrentModule) {\n\t\treturn false, nil\n\t}","sourceCodeStart":1191,"sourceCodeEnd":1227,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/modfunc.go#L1191-L1227","documentation":"loadContextualGitArg resolves a contextual git argument (auto-injected GitRepository/GitRef) by inspecting the argument's declared object type name and building the matching dagql ID. The switch only handles \"GitRepository\" and \"GitRef\"; any other object type reaching this loader falls into the default branch and throws this error. It is an internal invariant violation: the argument was routed to the git contextual loader but its type is not a supported git contextual type.","triggerScenarios":"A FunctionArg is declared with an object type other than GitRepository/GitRef but is dispatched to loadContextualGitArg, or a new contextual git object type is added to the schema without extending the switch in core/modfunc.go.","commonSituations":"Dagger core/schema development: adding a new contextual git argument type (e.g. GitTag) without updating loadContextualGitArg; constructing module function call inputs from stale or hand-built TypeDefs where DefaultPath routing sends a non-git object here.","solutions":["Inspect the argument's TypeDef object name in the error message and confirm it is actually a git contextual type","Add a case for the new object type in the switch in loadContextualGitArg (core/modfunc.go:1188)","Fix the argument's TypeDef/routing so only GitRepository and GitRef arguments reach loadContextualGitArg"],"exampleFix":"// before (new type missing)\ndefault:\n\treturn nil, fmt.Errorf(\"unknown git contextual argument type %q\", name)\n// after\ncase \"GitTag\":\n\tvar tag dagql.ObjectResult[*GitTag]\n\tif err := dag.Select(ctx, git, &tag, dagql.Selector{Field: \"tag\"}); err != nil {\n\t\treturn nil, err\n\t}\n\ttagID, err := tag.ID()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn dagql.NewID[*GitTag](tagID), nil","handlingStrategy":"validation","validationCode":"if arg.TypeDef.Self().Kind != TypeDefKindObject {\n\treturn fmt.Errorf(\"argument %s is not an object; cannot be a git contextual arg\", arg.OriginalName)\n}\nname := arg.TypeDef.Self().AsObject.Value.Self().Name\nif name != \"GitRepository\" && name != \"GitRef\" {\n\treturn fmt.Errorf(\"unsupported git contextual type %q\", name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only route GitRepository/GitRef arguments to the git contextual loader","When adding new contextual git types, extend the switch in loadContextualGitArg in the same change","Add a unit test enumerating all supported contextual argument types"],"tags":["dagger","git","contextual-argument","internal-invariant"],"backgroundTag":"unknown-contextual-argument-type","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}