siyuan-note/siyuan · error
encrypted HEIF cache requires a notebook ID
Error message
encrypted HEIF cache requires a notebook ID
What it means
heif.GetOrCreate caches decoded HEIF previews/thumbnails. When options.Encrypted is true, cache entries must be namespaced per notebook, so a non-empty BoxID is mandatory; the function rejects encrypted requests without one before doing any decode work.
Solutions
- Populate Options.BoxID with the owning notebook's ID whenever Encrypted is true.
- If the image is not in an encrypted notebook, set Encrypted=false instead of leaving Encrypted=true with no BoxID.
- Fix the upstream caller (writeHEIFPreview path) to thread the box ID through to the cache call.
Example fix
// before
res, err := heif.GetOrCreate(ctx, src, heif.Options{Mode: heif.ModePreview, Encrypted: true})
// after
res, err := heif.GetOrCreate(ctx, src, heif.Options{Mode: heif.ModePreview, Encrypted: true, BoxID: boxID}) Defensive patterns
Strategy: validation
Validate before calling
if opts.Encrypted && opts.BoxID == "" {
return errors.New("BoxID is required for encrypted HEIF caching")
} Try / catch
res, err := heif.GetOrCreate(ctx, src, opts)
if err != nil && strings.Contains(err.Error(), "requires a notebook ID") {
// fix Options and retry
} Prevention
- Thread the notebook ID through all asset-preview call sites
- Build Options via a constructor that enforces Encrypted=>BoxID
- Add a unit test mirroring TestGetOrCreateValidatesOptionsBeforeDecode for new callers
When it happens
Trigger: Calling heif.GetOrCreate with Options{Encrypted: true, BoxID: ""} — e.g. a preview writer (writeHEIFPreview) that failed to propagate the notebook ID for an image inside an encrypted notebook.
Common situations: Rendering HEIF assets in encrypted notebooks where the caller dropped the box context, or test harnesses constructing Options manually and omitting BoxID.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- empty HEIF image
- Argon2id KeyLength must be 32
- Argon2id Memory too low (minimum 64 MB)
- cannot save incomplete notebook crypto configuration
- Conf.Language(317)
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/7dac842b12387c86.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/heif/cache.go:92
memoryCacheItems = map[string]*list.Element{}
memoryCacheBytes int
)
func IsPath(path string) bool {
path = strings.ToLower(path)
if index := strings.IndexAny(path, "?#"); index >= 0 {
path = path[:index]
}
ext := filepath.Ext(path)
return ext == ".heic" || ext == ".heif"
}
func GetOrCreate(ctx context.Context, source []byte, options Options) (Result, error) {
if options.Mode != ModePreview && options.Mode != ModeThumbnail {
return Result{}, ErrInvalidMode
}
if options.Encrypted && options.BoxID == "" {
return Result{}, errors.New("encrypted HEIF cache requires a notebook ID")
}
if len(source) == 0 {
return Result{}, errors.New("empty HEIF image")
}
if len(source) > MaxInputBytes {
return Result{}, ErrInputTooLarge
}
if err := ctx.Err(); err != nil {
return Result{}, err
}
digest := cacheDigest(source, options.Mode)
etag := `"heif-` + digest + `"`
cacheKey := digest
if options.Encrypted {
cacheKey = options.BoxID + ":" + digest
if data := getMemoryCache(cacheKey); data != nil {
return Result{Data: data, ETag: etag}, nilView on GitHub (pinned to 9f775e8a12)