{"record":{"id":"4bf713a083d279db","repo":"dagger/dagger","slug":"encode-persisted-env-file-nil-env-file","errorCode":null,"errorMessage":"encode persisted env file: nil env file","messagePattern":"encode persisted env file: nil env file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/envfile.go","lineNumber":56,"sourceCode":"\t_ dagql.PersistedObjectDecoder = (*EnvFile)(nil)\n)\n\nfunc (*EnvFile) Type() *ast.Type {\n\treturn &ast.Type{\n\t\tNamedType: \"EnvFile\",\n\t\tNonNull:   true,\n\t}\n}\n\nfunc (*EnvFile) TypeDescription() string {\n\treturn \"A collection of environment variables.\"\n}\n\nfunc (ef *EnvFile) EncodePersistedObject(ctx context.Context, cache dagql.PersistedObjectCache) (dagql.PersistedObjectEncoding, error) {\n\t_ = ctx\n\t_ = cache\n\tif ef == nil {\n\t\treturn dagql.PersistedObjectEncoding{}, fmt.Errorf(\"encode persisted env file: nil env file\")\n\t}\n\treturn encodePersistedObjectPayload(ef)\n}\n\nfunc (*EnvFile) DecodePersistedObject(ctx context.Context, dag *dagql.Server, _ uint64, _ *dagql.ResultCall, payload json.RawMessage) (dagql.Typed, error) {\n\t_ = ctx\n\t_ = dag\n\tvar ef EnvFile\n\tif err := json.Unmarshal(payload, &ef); err != nil {\n\t\treturn nil, fmt.Errorf(\"decode persisted env file payload: %w\", err)\n\t}\n\treturn &ef, nil\n}\n\n// Len returns the number of variables in the EnvFile\nfunc (ef *EnvFile) Len() int {\n\treturn len(ef.Environ)\n}","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/envfile.go#L38-L74","documentation":"Guard in EnvFile.EncodePersistedObject: fires when the receiver ef is nil when dagql tries to persist an EnvFile result. A nil EnvFile cannot be marshaled into a persisted payload, so this sentinel check rejects it explicitly.","triggerScenarios":"Thrown at core/envfile.go:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure a non-nil EnvFile is produced before the result is persisted","Trace the upstream construction path that yielded a nil EnvFile"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}