siyuan-note/siyuan · error

view [ ] not found

Error message

view [%s] not found

What it means

When hiding/showing a field across multiple views (setAttrViewViewFields... path), the kernel resolves each requested view ID via attrView.GetView. A nil result means the attribute view has no view with that ID, so the operation aborts with the view ID in the message.

Solutions

  1. Re-read the attribute view and confirm the view ID exists in its "views" array
  2. Remove or correct the invalid entry in the viewIDs list
  3. Refresh any cached view IDs in the plugin after view add/delete operations

Example fix

// before
setAttrViewFieldHidden(avID, ["staleViewID"], keyID, true)
// after
const view = (await getBlockAttr(avID)).views.find(v => v.id === viewID); // verify first
setAttrViewFieldHidden(avID, [view.id], keyID, true)
Defensive patterns

Strategy: validation

Validate before calling

const av = await getAttributeView(avID);
const missing = viewIDs.filter(id => !av.views.some(v => v.id === id));
if (missing.length) throw new Error(`unknown view IDs: ${missing.join(",")}`);

Type guard

const viewExists = (av: {views: {id: string}[]}, viewID: string): boolean => av.views.some(v => v.id === viewID);

Try / catch

try { await setAttrViewFieldHidden(avID, viewIDs, keyID, hidden); } catch (e) { if (String(e).includes("not found")) { await refreshAvCache(avID); } else throw e; }

Prevention

When it happens

Trigger: Calling the set-attribute-view-field-hidden style API with a viewIDs array containing a deleted, renamed (re-created), or mistyped view ID.

Common situations: Stale IDs cached by a plugin after the user deleted or duplicated the view; typos when hand-crafting API calls; operating on an old snapshot of the .av JSON.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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

Appendix: source

Thrown at kernel/model/attribute_view.go:6986

	if err != nil {
		return
	}
	err = av.SaveAttributeView(attrView)
	return
}

func setAttributeViewFieldsHidden(attrView *av.AttributeView, keyID string, viewIDs []string, hidden bool) (err error) {
	var fields []*av.BaseField
	seen := map[string]bool{}
	for _, viewID := range viewIDs {
		if seen[viewID] {
			continue
		}
		seen[viewID] = true

		view := attrView.GetView(viewID)
		if nil == view {
			return fmt.Errorf("view [%s] not found", viewID)
		}
		field := getAttributeViewField(view, keyID)
		if nil == field {
			return fmt.Errorf("field [%s] not found in view [%s]", keyID, viewID)
		}
		fields = append(fields, field)
	}

	if 1 > len(fields) {
		return errors.New("view IDs is empty")
	}
	for _, field := range fields {
		field.Hidden = hidden
	}
	return
}

func getAttributeViewField(view *av.View, keyID string) (ret *av.BaseField) {

View on GitHub (pinned to 9f775e8a12)