siyuan-note/siyuan · error

invalid box id

Error message

invalid box id

What it means

Sentinel ErrInvalidBoxID. Returned by ParseAttributeViewInBox and encrypted_hook.go when a non-empty boxID fails ast.IsNodeIDPattern. The box id must be a valid node id or empty (empty means global/normal notebook); any other shape is rejected before lookup.

Source

Thrown at kernel/av/av.go:1295

	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. Pass the notebook's actual id (matches ^\d{14}[0-9a-z]+$), or pass empty string for the global/normal case.
  2. Do not send notebook display names or paths as boxID.
  3. Validate with the same IsNodeIDPattern check before the call.

Example fix

// before
ParseAttributeViewInBox(avID, "my-notebook")  // name, not id

// after: use the notebook id, or empty for global
ParseAttributeViewInBox(avID, notebookID)      // valid id
ParseAttributeViewInBox(avID, "")              // global lookup
Defensive patterns

Strategy: validation

Validate before calling

if boxID != "" && !ast.IsNodeIDPattern(boxID) {
    return fmt.Errorf("not a valid box id: %q", boxID)
}

Type guard

// TypeScript guard
function isValidBoxID(boxID: string): boolean {
  return boxID === "" || /^\d{14}[0-9a-z]+$/.test(boxID)
}

Prevention

When it happens

Trigger: Calling ParseAttributeViewInBox (or an AV API that forwards boxID) with a boxID like 'abc', a notebook name, a path, or a malformed string. Passing a block id as boxID also fails the pattern.

Common situations: Confusing notebook id with notebook name; passing a view id or block id in the boxID slot; frontend sending the URL slug instead of the id.

Related errors


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