{"record":{"id":"0a2485065841b117","repo":"dagger/dagger","slug":"encode-persisted-git-bundle-missing-bundle-file","errorCode":null,"errorMessage":"encode persisted git bundle: missing bundle file","messagePattern":"encode persisted git bundle: missing bundle file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/git_bundle.go","lineNumber":131,"sourceCode":"\tif !ok {\n\t\treturn nil, fmt.Errorf(\"attach git bundle file: unexpected result %T\", attached)\n\t}\n\tbundle.File = file\n\treturn []dagql.AnyResult{file}, nil\n}\n\ntype persistedGitBundlePayload struct {\n\tFileResultID     uint64          `json:\"fileResultID\"`\n\tVersion          int             `json:\"version\"`\n\tObjectFormat     string          `json:\"objectFormat\"`\n\tRefs             []*GitBundleRef `json:\"refs\"`\n\tPrerequisiteSHAs []string        `json:\"prerequisiteSHAs,omitempty\"`\n}\n\nfunc (bundle *GitBundle) EncodePersistedObject(ctx context.Context, cache dagql.PersistedObjectCache) (dagql.PersistedObjectEncoding, error) {\n\t_ = ctx\n\tif bundle == nil || bundle.File.Self() == nil {\n\t\treturn dagql.PersistedObjectEncoding{}, fmt.Errorf(\"encode persisted git bundle: missing bundle file\")\n\t}\n\tfileID, err := encodePersistedObjectRef(cache, bundle.File, \"git bundle file\")\n\tif err != nil {\n\t\treturn dagql.PersistedObjectEncoding{}, err\n\t}\n\tpayload, err := json.Marshal(persistedGitBundlePayload{\n\t\tFileResultID:     fileID,\n\t\tVersion:          bundle.Version,\n\t\tObjectFormat:     bundle.ObjectFormat,\n\t\tRefs:             bundle.Clone().Refs,\n\t\tPrerequisiteSHAs: slices.Clone(bundle.PrerequisiteSHAs),\n\t})\n\tif err != nil {\n\t\treturn dagql.PersistedObjectEncoding{}, fmt.Errorf(\"marshal persisted git bundle: %w\", err)\n\t}\n\treturn encodePersistedObjectRawJSON(payload), nil\n}\n","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/git_bundle.go#L113-L149","documentation":"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.","triggerScenarios":"Calling EncodePersistedObject on a GitBundle constructed in memory without a file attached, or after AttachDependencyResults failed/was skipped, or on a nil *GitBundle.","commonSituations":"A failed gitBundle creation path left a half-initialized GitBundle in the cache; replay of a partially-attached persisted object.","solutions":["Ensure the GitBundle was created via ParseGitBundle/ImportGitBundle with a valid file before persisting","Check that AttachDependencyResults ran successfully prior to encoding","Fix upstream code that returns a GitBundle without setting bundle.File"],"exampleFix":"// before\nbundle := &GitBundle{Version: 2}\n// after\nfile, _ := parseGitBundleFromFile(ctx)\nbundle := &GitBundle{Version: 2, File: file}","handlingStrategy":"validation","validationCode":"if bundle == nil || bundle.File == nil || bundle.File.Self() == nil {\n\treturn fmt.Errorf(\"bundle file must be attached before persisting\")\n}","typeGuard":"func hasBundleFile(b *GitBundle) bool { return b != nil && b.File != nil && b.File.Self() != nil }","tryCatchPattern":"enc, err := bundle.EncodePersistedObject(ctx, cache)\nif err != nil {\n\tif strings.Contains(err.Error(), \"missing bundle file\") {\n\t\t// re-run Parse/Import to rebuild the bundle\n\t}\n\treturn err\n}","preventionTips":["Always construct GitBundle via ParseGitBundle/ImportGitBundle","Assert bundle.File is set right after construction","Handle AttachDependencyResults errors before encoding"],"tags":["dagger","git","serialization","null-reference"],"backgroundTag":"missing-required-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"}