dagger/dagger · error

unknown git contextual argument type

Error message

unknown git contextual argument type %q

What it means

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.

Solutions

  1. Inspect the argument's TypeDef object name in the error message and confirm it is actually a git contextual type
  2. Add a case for the new object type in the switch in loadContextualGitArg (core/modfunc.go:1188)
  3. Fix the argument's TypeDef/routing so only GitRepository and GitRef arguments reach loadContextualGitArg

Example fix

// before (new type missing)
default:
	return nil, fmt.Errorf("unknown git contextual argument type %q", name)
// after
case "GitTag":
	var tag dagql.ObjectResult[*GitTag]
	if err := dag.Select(ctx, git, &tag, dagql.Selector{Field: "tag"}); err != nil {
		return nil, err
	}
	tagID, err := tag.ID()
	if err != nil {
		return nil, err
	}
	return dagql.NewID[*GitTag](tagID), nil
Defensive patterns

Strategy: validation

Validate before calling

if arg.TypeDef.Self().Kind != TypeDefKindObject {
	return fmt.Errorf("argument %s is not an object; cannot be a git contextual arg", arg.OriginalName)
}
name := arg.TypeDef.Self().AsObject.Value.Self().Name
if name != "GitRepository" && name != "GitRef" {
	return fmt.Errorf("unsupported git contextual type %q", name)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/7863c2c299bbee40. Report an issue: GitHub.

Appendix: source

Thrown at core/modfunc.go:1209

		if err != nil {
			return nil, fmt.Errorf("get contextual git repository ID: %w", err)
		}
		return dagql.NewID[*GitRepository](gitID), nil
	case "GitRef":
		var gitRef dagql.ObjectResult[*GitRef]
		err := dag.Select(ctx, git, &gitRef,
			dagql.Selector{Field: "head"},
		)
		if err != nil {
			return nil, fmt.Errorf("load contextual git ref: %w", err)
		}
		gitRefID, err := gitRef.ID()
		if err != nil {
			return nil, fmt.Errorf("get contextual git ref ID: %w", err)
		}
		return dagql.NewID[*GitRef](gitRefID), nil
	default:
		return nil, fmt.Errorf("unknown git contextual argument type %q", arg.TypeDef.Self().AsObject.Value.Self().Name)
	}
}

// callerInModuleFunction reports whether ctx is executing inside a module
// function body. It keys off an active function call, not merely a module in
// context: a direct client (CLI/SDK) and schema-walking flows like `dagger
// generate` load a module but run no function, and must still be allowed to
// auto-inject a Workspace. ErrNoCurrentModule is the direct-client signal and is
// swallowed; any other error is a real lookup failure.
func callerInModuleFunction(ctx context.Context) (bool, error) {
	query, err := CurrentQuery(ctx)
	if err != nil {
		return false, fmt.Errorf("get current query: %w", err)
	}
	fnCall, err := query.CurrentFunctionCall(ctx)
	if errors.Is(err, ErrNoCurrentModule) {
		return false, nil
	}

View on GitHub (pinned to 82ba2681db)