{"record":{"id":"17c5956c11646604","repo":"siyuan-note/siyuan","slug":"invalid-relation-block-id-s","errorCode":null,"errorMessage":"invalid relation block ID [%s]","messagePattern":"invalid relation block ID \\[(.+?)\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/new_item_template.go","lineNumber":424,"sourceCode":"\t\t\t\t\treturn nil, fmt.Errorf(\"invalid asset type [%s]\", asset.Type)\n\t\t\t\t}\n\t\t\t\tassets = append(assets, asset)\n\t\t\t}\n\t\t}\n\t\tvalue.MAsset = assets\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.Checkbox, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeCheckbox:\n\t\tif nil == value.Checkbox {\n\t\t\treturn nil, errors.New(\"checkbox value is missing\")\n\t\t}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Relation = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tcase KeyTypeRelation:\n\t\tif nil == value.Relation {\n\t\t\treturn nil, errors.New(\"relation value is missing\")\n\t\t}\n\t\tfor _, blockID := range value.Relation.BlockIDs {\n\t\t\tif !ast.IsNodeIDPattern(blockID) {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid relation block ID [%s]\", blockID)\n\t\t\t}\n\t\t}\n\t\tvalue.Text, value.Number, value.Date, value.MSelect, value.URL, value.Email, value.Phone, value.MAsset, value.Checkbox = nil, nil, nil, nil, nil, nil, nil, nil, nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported value type [%s]\", key.Type)\n\t}\n\tvalue.Block, value.Template, value.Created, value.Updated, value.Rollup = nil, nil, nil, nil, nil\n\tvalue.ID = \"\"\n\tvalue.KeyID = \"\"\n\tvalue.BlockID = \"\"\n\tvalue.Type = key.Type\n\tvalue.IsDetached = false\n\tvalue.CreatedAt = 0\n\tvalue.UpdatedAt = 0\n\tvalue.IsRenderAutoFill = false\n\tif nil != value.Number {\n\t\tvalue.Number.Format = key.NumberFormat\n\t\tvalue.Number.FormattedContent = \"\"","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/av/new_item_template.go#L406-L442","documentation":"Thrown inside normalizeNewItemTemplateValue (kernel/av/new_item_template.go:422-424) during the KeyTypeRelation branch, after confirming value.Relation is non-nil. Each string in value.Relation.BlockIDs is validated against ast.IsNodeIDPattern, which expects a 20-character alphanumeric SiYuan block ID. The first ID that fails the pattern check triggers this formatted error with the offending ID string.","triggerScenarios":"A relation-type template field value contains one or more block IDs that do not match the SiYuan node ID pattern (not 20 chars, contains invalid characters, or is empty).","commonSituations":"Using human-readable names instead of block IDs as relation targets; stale block IDs from deleted blocks; copy-pasting truncated IDs; manually constructing relation values without using real block IDs from the target AV.","solutions":["Replace invalid IDs with valid 20-character SiYuan block IDs obtained from the target Attribute View's blocks","Verify each ID with ast.IsNodeIDPattern(id) before submitting","If a referenced block was deleted, remove its ID from the BlockIDs list"],"exampleFix":"// before\nvalue.Relation = &av.ValueRelation{BlockIDs: []string{\"my-task\", \"short\"}}\n// after\nvalue.Relation = &av.ValueRelation{BlockIDs: []string{\"20240101120000abcdef01\", \"20240101120002fedcba03\"}}","handlingStrategy":"validation","validationCode":"import \"github.com/88250/lute/ast\"\n\nfunc validateRelationBlockIDs(value *av.Value) error {\n    if value.Relation == nil {\n        return nil\n    }\n    for _, id := range value.Relation.BlockIDs {\n        if !ast.IsNodeIDPattern(id) {\n            return fmt.Errorf(\"invalid block ID %q: must be a 20-char SiYuan node ID\", id)\n        }\n    }\n    return nil\n}","typeGuard":"func isValidBlockID(id string) bool {\n    return ast.IsNodeIDPattern(id)\n}","tryCatchPattern":null,"preventionTips":["Always use real SiYuan block IDs obtained from the target Attribute View, not human-readable names","Validate every BlockID with ast.IsNodeIDPattern before submitting","Remove stale block IDs of deleted blocks before saving the template"],"tags":["attribute-view","validation","relation","block-id","go"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}