dagger/dagger · error

encode persisted git bundle: missing bundle file

Error message

encode persisted git bundle: missing bundle file

What it means

GitBundle.EncodePersistedObject refuses to serialize a bundle whose File field is nil (bundle == nil or bundle.File.Self() == nil). A bundle without its backing file cannot be persisted, since the file is the bundle's primary dependency reference.

Source

Thrown at core/git_bundle.go:131

	if !ok {
		return nil, fmt.Errorf("attach git bundle file: unexpected result %T", attached)
	}
	bundle.File = file
	return []dagql.AnyResult{file}, nil
}

type persistedGitBundlePayload struct {
	FileResultID     uint64          `json:"fileResultID"`
	Version          int             `json:"version"`
	ObjectFormat     string          `json:"objectFormat"`
	Refs             []*GitBundleRef `json:"refs"`
	PrerequisiteSHAs []string        `json:"prerequisiteSHAs,omitempty"`
}

func (bundle *GitBundle) EncodePersistedObject(ctx context.Context, cache dagql.PersistedObjectCache) (dagql.PersistedObjectEncoding, error) {
	_ = ctx
	if bundle == nil || bundle.File.Self() == nil {
		return dagql.PersistedObjectEncoding{}, fmt.Errorf("encode persisted git bundle: missing bundle file")
	}
	fileID, err := encodePersistedObjectRef(cache, bundle.File, "git bundle file")
	if err != nil {
		return dagql.PersistedObjectEncoding{}, err
	}
	payload, err := json.Marshal(persistedGitBundlePayload{
		FileResultID:     fileID,
		Version:          bundle.Version,
		ObjectFormat:     bundle.ObjectFormat,
		Refs:             bundle.Clone().Refs,
		PrerequisiteSHAs: slices.Clone(bundle.PrerequisiteSHAs),
	})
	if err != nil {
		return dagql.PersistedObjectEncoding{}, fmt.Errorf("marshal persisted git bundle: %w", err)
	}
	return encodePersistedObjectRawJSON(payload), nil
}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Ensure the GitBundle was created via ParseGitBundle/ImportGitBundle with a valid file before persisting
  2. Check that AttachDependencyResults ran successfully prior to encoding
  3. Fix upstream code that returns a GitBundle without setting bundle.File

Example fix

// before
bundle := &GitBundle{Version: 2}
// after
file, _ := parseGitBundleFromFile(ctx)
bundle := &GitBundle{Version: 2, File: file}
Defensive patterns

Strategy: validation

Validate before calling

if bundle == nil || bundle.File == nil || bundle.File.Self() == nil {
	return fmt.Errorf("bundle file must be attached before persisting")
}

Type guard

func hasBundleFile(b *GitBundle) bool { return b != nil && b.File != nil && b.File.Self() != nil }

Try / catch

enc, err := bundle.EncodePersistedObject(ctx, cache)
if err != nil {
	if strings.Contains(err.Error(), "missing bundle file") {
		// re-run Parse/Import to rebuild the bundle
	}
	return err
}

Prevention

When it happens

Trigger: Calling EncodePersistedObject on a GitBundle constructed in memory without a file attached, or after AttachDependencyResults failed/was skipped, or on a nil *GitBundle.

Common situations: A failed gitBundle creation path left a half-initialized GitBundle in the cache; replay of a partially-attached persisted object.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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