siyuan-note/siyuan · error · ErrAttributeViewNotFound

attribute view not found

Error message

attribute view not found

What it means

Sentinel error av.ErrAttributeViewNotFound (kernel/av/av.go:1293). An attribute view (database) is stored as storage/av/<avID>.json (notebook-level path for encrypted boxes); when a database block references an avID whose storage file cannot be found, rendering (kernel/model/attribute_view_render.go) and API handlers (kernel/api/av.go:1327, surfaced as ret.Msg) return this error. It means the reference exists but the backing data file does not.

Solutions

  1. Check whether data/storage/av/<avID>.json (or the notebook-level path for encrypted notebooks) exists on disk
  2. Trigger a full re-sync or re-download the cloud data repo so missing av files are restored
  3. If the av is genuinely gone, remove the stale reference: delete the database block or clear its custom-avs attribute, then recreate the database
  4. Search SQL (blocks with custom-avs containing the id) to find all blocks referencing the missing av before deleting
Defensive patterns

Strategy: try-catch

Validate before calling

// Check the backing file before rendering or operating on an av reference
avPath := filepath.Join(util.DataDir, "storage", "av", avID+".json")
if !filelock.IsExist(avPath) {
    // handle the missing-av case explicitly instead of calling into the kernel
}

Try / catch

avView, err := av.ParseAttributeView(avID)
switch {
case errors.Is(err, av.ErrAttributeViewNotFound):
    // stale reference: remove the block's custom-avs attr, hide the database block, or prompt the user to re-sync
case errors.Is(err, av.ErrInvalidAttributeViewID):
    // reject the caller-supplied id
case err != nil:
    return err // unexpected
}

Prevention

When it happens

Trigger: Rendering or querying a database block after its storage/av/<id>.json was deleted or never synced; partial sync where the document synced but the av storage file did not; switching workspaces; restoring a cloud snapshot that lacks the av files; manually pruning data/storage/av.

Common situations: Multi-device sync races (device A creates the av, device B gets the doc but misses the av file); users hand-cleaning the data directory; interrupted repo sync/checkout; av files excluded by backup tooling.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: 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 afa823b6b4)