dagger/dagger · error

decode persisted file chown lazy: %w

Error message

decode persisted file chown lazy: %w

What it means

Wraps a json.Unmarshal failure decoding a persisted 'chown' lazy payload (persistedFileChownLazy) into a FileChownLazy. The payload stores a parent File and the owner (chown) target; invalid or schema-drifted JSON blocks rehydration. Same persisted-lazy-state corruption/compatibility family as errors 660-663.

Source

Thrown at core/file.go:486

			Search:      persisted.Search,
			Replacement: persisted.Replacement,
			FirstFrom:   persisted.FirstFrom,
			All:         persisted.All,
		}, nil
	case persistedFileLazyKindWithTimestamps:
		var persisted persistedFileWithTimestampsLazy
		if err := json.Unmarshal(payload, &persisted); err != nil {
			return nil, fmt.Errorf("decode persisted file withTimestamps lazy: %w", err)
		}
		parent, err := loadPersistedObjectResultByResultID[*File](ctx, dag, persisted.ParentResultID, "file withTimestamps parent")
		if err != nil {
			return nil, err
		}
		return &FileWithTimestampsLazy{LazyState: NewLazyState(), Parent: parent, Timestamp: persisted.Timestamp}, nil
	case persistedFileLazyKindChown:
		var persisted persistedFileChownLazy
		if err := json.Unmarshal(payload, &persisted); err != nil {
			return nil, fmt.Errorf("decode persisted file chown lazy: %w", err)
		}
		parent, err := loadPersistedObjectResultByResultID[*File](ctx, dag, persisted.ParentResultID, "file chown parent")
		if err != nil {
			return nil, err
		}
		return &FileChownLazy{LazyState: NewLazyState(), Parent: parent, Owner: persisted.Owner}, nil
	default:
		return nil, fmt.Errorf("decode persisted file lazy payload: unsupported lazy kind %q", lazyKind)
	}
}

func (lazy *FileBlobLazy) Evaluate(ctx context.Context, file *File) error {
	return lazy.LazyState.Evaluate(ctx, "File.blob", func(ctx context.Context) error {
		if dir, _ := filepath.Split(lazy.Filename); dir != "" {
			return fmt.Errorf("file name %q must not contain a directory", lazy.Filename)
		}
		if err := ValidateFileName(lazy.Filename); err != nil {
			return err

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Regenerate state by clearing the bad persisted entry and re-running
  2. Match engine versions across all environments touching the state
  3. Verify persistedFileChownLazy JSON tags match the encoder
  4. Examine the wrapped error to identify the failing field
Defensive patterns

Strategy: try-catch

Try / catch

lazy, err := decodePersistedFileLazy(ctx, dag, payload, kind)
if err != nil {
    if strings.Contains(err.Error(), "decode persisted file chown lazy") {
        return reapplyChown(ctx, dag)
    }
    return err
}

Prevention

When it happens

Trigger: Decoding a persistedFileLazyKindChown payload: malformed JSON, Owner field type mismatch (e.g. owner encoded as string vs structured object), or payload written by an incompatible engine version.

Common situations: Engine version skew; corrupted engine state; Owner serialization format changed between versions; shared CI cache carrying foreign payloads.

Understand the failure class

Background: "failed to unmarshal" / json.Unmarshal errors: why parsing a response into a Go struct fails and how to fix it — this error's family across 23 libraries.

Related errors


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