siyuan-note/siyuan · error · ErrAttributeViewNotFound

attribute view not found

Error message

attribute view not found

What it means

Sentinel ErrAttributeViewNotFound. Returned by model/attribute_view_render.go when ParseAttributeView yields nil for a requested avID during content rendering, export, or attribute lookups (multiple sites around lines 435, 1057, 1100, 1141, 1197, 1223). It means the AV JSON file does not exist on disk or could not be located for the given id.

Source

Thrown at kernel/av/av.go:1293

	}

	av := filepath.Join(util.DataDir, "storage", "av")
	ret = filepath.Join(av, avID+".json")
	if !gulu.File.IsDir(av) {
		if err := os.MkdirAll(av, 0755); err != nil {
			logging.LogErrorf("create attribute view dir failed: %s", err)
			return
		}
	}
	return
}

func GetAttributeViewI18n(key string) string {
	return util.AttrViewLangs[util.Lang][key].(string)
}

var (
	ErrAttributeViewNotFound  = errors.New("attribute view not found")
	ErrInvalidAttributeViewID = errors.New("invalid attribute view id")
	ErrInvalidBoxID           = errors.New("invalid box id")
	ErrViewNotFound           = errors.New("view not found")
	ErrKeyNotFound            = errors.New("key not found")
	ErrItemNotFound           = errors.New("item not found")
	ErrWrongLayoutType        = errors.New("wrong layout type")
	ErrInvalidColumnAlign     = errors.New("invalid column align")
	ErrSpecTooNew             = errors.New("attribute view spec is too new")
	ErrFilterTooDeep          = errors.New("filter nesting depth exceeds the maximum allowed")
)

const (
	NodeAttrNameAvs        = "custom-avs"                 // 用于标记块所属的属性视图,逗号分隔 av id
	NodeAttrView           = "custom-sy-av-view"          // 用于标记块所属的属性视图视图 view id Database block support specified view https://github.com/siyuan-note/siyuan/issues/10443
	NodeAttrVisibleViewIDs = "custom-sy-av-visible-views" // 用于标记数据库块显示的视图 ID,逗号分隔
	NodeAttrViewStaticText = "custom-sy-av-s-text"        // 用于标记块所属的属性视图静态文本 Database-bound block primary key supports setting static anchor text https://github.com/siyuan-note/siyuan/issues/10049

	NodeAttrViewNames = "av-names" // 用于临时标记块所属的属性视图名称,空格分隔

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Verify the avID exists: GET /api/av/getAttributeView with the id and check for the same error.
  2. If the AV was deleted, remove the dangling reference from the block's custom-avs attribute.
  3. If it should exist, check data/storage/av/<avID>.json is present and the notebook is mounted.
  4. For encrypted notebooks, confirm the notebook is unlocked so the AV can be decrypted and located.

Example fix

// before
av, err := av.ParseAttributeView(avID)
render(av)

// after: handle the not-found sentinel explicitly
av, err := av.ParseAttributeView(avID)
if errors.Is(err, av.ErrAttributeViewNotFound) || av == nil {
    // drop the stale reference instead of rendering a nil view
    clearBlockAVRef(block, avID)
    return
}
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the AV exists before rendering
if !av.IsAttributeViewExist(avID) {
    return // or clear the block's custom-avs reference
}

Try / catch

avView, err := av.ParseAttributeView(avID)
if errors.Is(err, av.ErrAttributeViewNotFound) || avView == nil {
    // stale reference; do not render
    return
}

Prevention

When it happens

Trigger: Requesting render/content for an avID that was never created, was deleted, whose .json was removed manually, or that lives in a notebook not currently mounted. Also when a block references an avID via custom-avs that no longer resolves.

Common situations: Stale block attribute referencing a deleted database; data loss after a failed sync; manual deletion of files under data/storage/av/; referencing an AV from an unmounted/encrypted notebook without the key.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/f42f9f0b2b5230ae. Report an issue: GitHub.