siyuan-note/siyuan · error

view not found

Error message

view not found

What it means

Sentinel ErrViewNotFound — the most frequently thrown AV error. Returned when a requested view id is absent from the AV's Views list: GetFirstView returns it when there are no views at all; parseAttributeViewByPathInBox returns it when the AV JSON file does not exist; and many model-layer operations return it when the operation targets a view id not present in the loaded AV.

Source

Thrown at kernel/av/av.go:1296

	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. Refresh the AV's view list (GET /api/av/getAttributeView) and use a current view id.
  2. If the AV has no views, create one before issuing view-scoped operations.
  3. Handle ErrViewNotFound in the client by reloading the database block rather than retrying the stale op.
  4. Confirm the AV file exists (see error 90) when the missing-file overload is suspected.

Example fix

// before
op := &av.Operation{Action: "setview", id: lastViewID}
err := model.UpdateAttributeView(op)   // stale lastViewID -> view not found

// after: reload and use a live view id
attrView, _ := av.ParseAttributeView(avID)
viewID := attrView.Views[0].ID
op := &av.Operation{Action: "setview", id: viewID}
Defensive patterns

Strategy: try-catch

Try / catch

view, err := getRenderAttributeViewView(attrView, viewID, "", "", false)
if errors.Is(err, av.ErrViewNotFound) {
    // reload the database block and pick a live view; do not retry the stale id
    attrView, _ = av.ParseAttributeView(avID)
    view, err = attrView.GetFirstView()
}

Prevention

When it happens

Trigger: Calling a database operation (setfilter, setsort, setview, getview, render) with a view id that was deleted, never existed, or belongs to a different AV. Also when rendering a brand-new AV that has had no view created yet, or when the AV file itself is missing.

Common situations: Client holds stale state after another tab/session deleted or switched the view; a plugin reused a hardcoded view id; race between view deletion and an in-flight operation; AV file removed but block still references it.

Related errors


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