dagger/dagger · error

encode persisted env file: nil env file

Error message

encode persisted env file: nil env file

What it means

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.

Source

Thrown at core/envfile.go:56

	_ dagql.PersistedObjectDecoder = (*EnvFile)(nil)
)

func (*EnvFile) Type() *ast.Type {
	return &ast.Type{
		NamedType: "EnvFile",
		NonNull:   true,
	}
}

func (*EnvFile) TypeDescription() string {
	return "A collection of environment variables."
}

func (ef *EnvFile) EncodePersistedObject(ctx context.Context, cache dagql.PersistedObjectCache) (dagql.PersistedObjectEncoding, error) {
	_ = ctx
	_ = cache
	if ef == nil {
		return dagql.PersistedObjectEncoding{}, fmt.Errorf("encode persisted env file: nil env file")
	}
	return encodePersistedObjectPayload(ef)
}

func (*EnvFile) DecodePersistedObject(ctx context.Context, dag *dagql.Server, _ uint64, _ *dagql.ResultCall, payload json.RawMessage) (dagql.Typed, error) {
	_ = ctx
	_ = dag
	var ef EnvFile
	if err := json.Unmarshal(payload, &ef); err != nil {
		return nil, fmt.Errorf("decode persisted env file payload: %w", err)
	}
	return &ef, nil
}

// Len returns the number of variables in the EnvFile
func (ef *EnvFile) Len() int {
	return len(ef.Environ)
}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Ensure a non-nil EnvFile is produced before the result is persisted
  2. Trace the upstream construction path that yielded a nil EnvFile
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at core/envfile.go:56 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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