siyuan-note/siyuan · error
current document is not bound to the context filter target…
Error message
current document is not bound to the context filter target database
What it means
ErrAttributeViewContextNotBound signals that a context filter is configured on a database block, but the current document has not been resolved to any row IDs in the target database (filterContext.CurrentDocumentItemIDs is empty). The library refuses to proceed because context filtering requires the carrying document to actually map to database items. Callers like GetAttrViewAddingBlockDefaultValues and createAttributeViewItem raise it before computing defaults or creating items.
Solutions
- Bind the current document/block to the database by adding it as a row so CurrentDocumentItemIDs is populated before the call.
- Check filterContext.CurrentDocumentItemIDs length before calling and skip or surface a user-facing hint when it is empty.
- Remove the context filter from the database block if cross-document unbound usage is intended.
Example fix
// before
item, err := createAttributeViewItem(view, filterContext)
// after
if nil != filterContext && 1 > len(filterContext.CurrentDocumentItemIDs) {
return errors.New("block is not a row of the filtered database; bind it first")
}
item, err := createAttributeViewItem(view, filterContext) Defensive patterns
Strategy: validation
Validate before calling
if nil != filterContext && len(filterContext.CurrentDocumentItemIDs) == 0 {
// refuse to call; surface guidance to bind the document
} Prevention
- Only use context-filtered database blocks in documents that are actual rows of the database
- Check CurrentDocumentItemIDs before invoking default-value or item-creation APIs
- Strip context filters when moving database blocks into unbound documents
When it happens
Trigger: Calling GetAttrViewAddingBlockDefaultValues or createAttributeViewItem (kernel/model/attribute_view.go:368, :6246) with a non-nil filter context whose CurrentDocumentItemIDs has zero entries — i.e. the block embedding the database is not itself a row (item) of the filtered database.
Common situations: Embedding an attribute-view block in a document that is not bound to the database as a row; using a context-filtered database on a detached document; copying a filtered database block into a plain document without a carrier block.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- view not found
- attribute view drop target changed; retry the drag
- attribute view embedded base is missing
- attribute view groups changed; retry the drag
- attribute view instance is not set
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/6c78c03e31d14a3a.
Report an issue: GitHub.
Appendix: 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 9f775e8a12)