siyuan-note/siyuan · error
ErrAttributeViewContextNotBound
ErrAttributeViewContextNotBound
Error message
current document is not bound to the context filter target database
What it means
Sentinel error ErrAttributeViewContextNotBound means the current document resolved a context filter but no rows (CurrentDocumentItemIDs is empty) were bound to it — the document is not actually linked to the target database the filter points at. Callers refuse to create or default-fill attribute view items in this state.
Source
Thrown at kernel/av/context_filter.go:32
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package av
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"strings"
)
const AttributeViewContextFilterSpec = 1
var (
ErrInvalidAttributeViewContextFilter = errors.New("invalid attribute view context filter")
ErrAttributeViewContextNotBound = errors.New("current document is not bound to the context filter target database")
)
// AttributeViewContextFilter 描述物理数据库块独有的上下文筛选配置。
type AttributeViewContextFilter struct {
Spec int `json:"spec"`
KeyID string `json:"keyID"`
}
// AttributeViewContextFilterField 描述可用于物理数据库块上下文筛选的关联字段。
type AttributeViewContextFilterField struct {
ID string `json:"id"`
Name string `json:"name"`
Icon string `json:"icon"`
TargetAvID string `json:"targetAvID"`
}
// FilterContext 保存一次数据库块渲染所需的上下文筛选值,不参与持久化。
type FilterContext struct {View on GitHub (pinned to 8641553a1f)
Solutions
- Re-bind the document to the target database (insert the block as a database row) so CurrentDocumentItemIDs is populated
- Remove the stale context filter from the document if the binding is no longer wanted
- Verify the filter's keyID targets the database the document actually belongs to
Example fix
// before // filterContext exists but document has no bound rows -> err returned // after // add the block as a row in the target database so CurrentDocumentItemIDs contains its item ID
Defensive patterns
Strategy: type-guard
Validate before calling
if (filterContext && (!filterContext.currentDocumentItemIDs || filterContext.currentDocumentItemIDs.length === 0)) { rebindDocumentToDatabase(doc, db); } Type guard
function isBoundToDocument(fc) { return fc != null && Array.isArray(fc.currentDocumentItemIDs) && fc.currentDocumentItemIDs.length > 0; } Try / catch
try { return createItem(docID); } catch (e) { if (errors.is(e, ErrAttributeViewContextNotBound)) { await rebindDocument(docID); return createItem(docID); } throw e; } Prevention
- Re-check document-to-database binding after copy/move operations
- Remove stale context filters when unbinding documents
- Verify keyID targets the database the document is a row of
When it happens
Trigger: GetAttrViewAddingBlockDefaultValues or createAttributeViewItem with a filterContext whose CurrentDocumentItemIDs length is 0; TestResolveAttributeViewContextFilterMapsCarrierDocument checks the same condition.
Common situations: A document that previously embedded a database row binding was edited/unlinked; the context filter key exists but the document block is no longer a row of that database; copying a doc without its database binding.
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
- ErrInvalidAttributeViewContextFilter
- parse attribute view context filter: %w
- validate attribute view context filter target: %w
- attribute view not found
- invalid attribute view id
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/00c574bfd45dd108.
Report an issue: GitHub.