siyuan-note/siyuan · error

unsupported encrypted asset container version

Error message

unsupported encrypted asset container version

What it means

The decrypted metadata carries format-version fields (Spec and ContainerID). A legacy container (both fields empty) is accepted with the legacy spec; anything else must match the current encryptedAssetSpec and a full-size container ID. This error means the metadata decrypts fine but declares a container version this kernel does not support — typically a newer format written by a newer client, or a half-populated version field.

Solutions

  1. Upgrade the SiYuan kernel to the version that wrote the asset (check the client version that produced the data)
  2. If the metadata was corrupted/migrated partially, re-encrypt the asset from the original source to regenerate consistent Spec/ContainerID
  3. Verify integrity: a wrong-AAD decryption would fail earlier, so a decrypt-then-version-mismatch usually means a real format delta, not a wrong key
Defensive patterns

Strategy: fallback

Try / catch

plain, name, err := model.DecryptAssetWithName(box, disk, dek, data)
if err != nil && strings.Contains(err.Error(), "unsupported encrypted asset container version") {
    return fmt.Errorf("asset written by a newer SiYuan version; please upgrade the kernel: %w", err)
}

Prevention

When it happens

Trigger: Opening an encrypted asset written by a future SiYuan version with a different encryptedAssetSpec; metadata where only one of Spec/ContainerID is set (explicit empty or incomplete new format is deliberately not downgraded to legacy); tampered metadata.

Common situations: Downgraded kernel reading data produced by an upgraded client; sync propagating containers from a newer client; partial migration that populated one version field but not the other.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/a315563c5923e738. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/crypto.go:2344

}

func parseEncryptedAssetMetadata(data []byte) (*encryptedAssetMetadata, error) {
	metadata := &encryptedAssetMetadata{}
	if err := json.Unmarshal(data, metadata); err != nil {
		return nil, err
	}
	var version struct {
		Spec        json.RawMessage `json:"spec"`
		ContainerID json.RawMessage `json:"containerID"`
	}
	if err := json.Unmarshal(data, &version); err != nil {
		return nil, err
	}
	// 仅认证元数据同时缺少两个版本字段时按旧容器读取,显式空值或不完整的新格式不能降级。
	if len(version.Spec) == 0 && len(version.ContainerID) == 0 {
		metadata.Spec = encryptedAssetLegacySpec
	} else if metadata.Spec != encryptedAssetSpec || len(metadata.ContainerID) != encryptedAssetContainerIDSize {
		return nil, errors.New("unsupported encrypted asset container version")
	}
	if metadata.OriginalName == "" || metadata.OriginalName == "." ||
		filepath.Base(metadata.OriginalName) != metadata.OriginalName || strings.ContainsAny(metadata.OriginalName, `/\`) {
		return nil, errors.New("invalid encrypted asset original name")
	}
	if metadata.Size < 0 {
		return nil, errors.New("invalid encrypted asset content metadata")
	}
	chunks := uint64(metadata.Size) / encryptedAssetChunkSize
	if metadata.Size%encryptedAssetChunkSize != 0 || metadata.Size == 0 {
		chunks++
	}
	if metadata.Chunks != chunks {
		return nil, errors.New("invalid encrypted asset chunk count")
	}
	return metadata, nil
}

View on GitHub (pinned to 9f775e8a12)