{"record":{"id":"3eaee8aea61913ec","repo":"siyuan-note/siyuan","slug":"id-is-required-3eaee8","errorCode":null,"errorMessage":"--id is required","messagePattern":"--id is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/attr.go","lineNumber":44,"sourceCode":"\n\t\"github.com/siyuan-note/siyuan/kernel/model\"\n\t\"github.com/siyuan-note/siyuan/kernel/sql\"\n\n\t\"github.com/spf13/cobra\"\n)\n\nvar attrCmd = &cobra.Command{\n\tUse:   \"attr\",\n\tShort: \"Manage block attributes\",\n}\n\nvar attrGetCmd = &cobra.Command{\n\tUse:   \"get --id <id>\",\n\tShort: \"Get block attributes\",\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\tattrs := sql.GetBlockAttrs(id)\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\tdata, _ := json.MarshalIndent(attrs, \"\", \"  \")\n\t\t\tfmt.Println(string(data))\n\t\tdefault:\n\t\t\tprintAttrTable(attrs)\n\t\t}\n\t\treturn nil\n\t},\n}\n\nvar attrSetCmd = &cobra.Command{\n\tUse:   \"set --id <id> --attr name=value\",\n\tShort: \"Set block attributes\",\n\tLong: `Set custom attributes on a block.","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/attr.go#L26-L62","documentation":"The `attr get` subcommand requires the --id flag (block ID) but it was empty or omitted. Thrown by attrGetCmd.RunE at kernel/cli/cmd/attr.go:42-44. The ID is then passed to sql.GetBlockAttrs to read custom block attributes.","triggerScenarios":"Running `siyuan-kernel attr get` without --id, or passing an empty --id value.","commonSituations":"The user forgot the flag; a script variable holding the block ID was empty; the block ID was copied incorrectly.","solutions":["Pass the target block ID: `attr get --id 20260605100657-v080a4j`","If scripting, ensure the ID variable is non-empty before invoking","Use `attr get --help` to confirm the flag"],"exampleFix":"# before\nsiyuan-kernel attr get\n\n# after\nsiyuan-kernel attr get --id 20260605100657-v080a4j","handlingStrategy":"validation","validationCode":"if id == \"\" { return errors.New(\"--id is required\") }\n// Or: attrGetCmd.MarkFlagRequired(\"id\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mark --id required via cobra","In scripts, assert the block ID variable is non-empty before invoking","Copy the full block ID including the timestamp-prefix and 6-char suffix"],"tags":["cli","attr","validation","cobra","flags"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}