{"record":{"id":"907ecd7c574d5a4e","repo":"siyuan-note/siyuan","slug":"id-is-required-907ecd","errorCode":null,"errorMessage":"--id is required","messagePattern":"--id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/ref.go","lineNumber":41,"sourceCode":"\t\"text/tabwriter\"\n\n\t\"github.com/siyuan-note/siyuan/kernel/model\"\n\n\t\"github.com/spf13/cobra\"\n)\n\nvar refCmd = &cobra.Command{\n\tUse:   \"ref\",\n\tShort: \"Backlinks and references\",\n}\n\nvar refBacklinksCmd = &cobra.Command{\n\tUse:   \"backlinks --id <id>\",\n\tShort: \"Get backlinks for a block\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tid, _ := cmd.Flags().GetString(\"id\")\n\t\tif id == \"\" {\n\t\t\treturn fmt.Errorf(\"--id is required\")\n\t\t}\n\n\t\tkeyword, _ := cmd.Flags().GetString(\"keyword\")\n\t\tsortMode, _ := cmd.Flags().GetInt(\"sort\")\n\n\t\t_, backlinks, _, count, _ := model.GetBacklink2(id, keyword, \"\", sortMode, 0, model.Conf.Editor.BacklinkContainChildren)\n\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(backlinks, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tprintPathTable(backlinks, false)\n\t\t}\n\n\t\tfmt.Printf(\"\\n%d backlink(s)\\n\", count)\n\t\treturn nil\n\t},","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/ref.go#L23-L59","documentation":"Returned by the `ref backlinks` subcommand when --id is empty. Backlink lookup via model.GetBacklink2 requires a source block ID.","triggerScenarios":"Running `ref backlinks` with no --id flag or `--id \"\"`, before GetBacklink2 is invoked.","commonSituations":"Omitting the flag, assuming a default block, or a script variable that resolved to empty.","solutions":["Pass a valid block ID: `ref backlinks --id <block-id>`.","Obtain the block ID from the editor or `block` commands."],"exampleFix":"# before\nsiyuan ref backlinks\n# after\nsiyuan ref backlinks --id 202406011200-abcdef","handlingStrategy":"validation","validationCode":"[ -n \"$BLOCK_ID\" ] || { echo 'ref backlinks requires --id'; exit 1; }\nsiyuan ref backlinks --id \"$BLOCK_ID\"","typeGuard":"n/a (CLI flag validation)","tryCatchPattern":"n/a","preventionTips":["Backlink queries take a block ID; source it from the editor or block commands.","Validate the ID exists before running to avoid empty, confusing results."],"tags":["cli","ref","validation","missing-argument"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}