{"record":{"id":"980d41efe04bc59e","repo":"siyuan-note/siyuan","slug":"av-and-ids-are-required","errorCode":null,"errorMessage":"--av and --ids are required","messagePattern":"--av and --ids are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/database.go","lineNumber":288,"sourceCode":"\t\tsrcs := []map[string]any{src}\n\n\t\tif err := model.AddAttributeViewBlock(nil, srcs, avID, \"\", viewID, groupID, previousID, ignoreFill); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadAttrViewEntry(avID)\n\t\tfmt.Println(\"ok\")\n\t\treturn nil\n\t},\n}\n\nvar databaseItemRemoveCmd = &cobra.Command{\n\tUse:   \"remove --av <avID> --ids <id1,id2,...>\",\n\tShort: \"Remove rows from database\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tavID, _ := cmd.Flags().GetString(\"av\")\n\t\tidsStr, _ := cmd.Flags().GetString(\"ids\")\n\t\tif avID == \"\" || idsStr == \"\" {\n\t\t\treturn fmt.Errorf(\"--av and --ids are required\")\n\t\t}\n\t\tids := strings.Split(idsStr, \",\")\n\t\tfor i := range ids {\n\t\t\tids[i] = strings.TrimSpace(ids[i])\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would remove %d row(s) from database %s\\n\", len(ids), avID)\n\t\t\treturn nil\n\t\t}\n\n\t\tif err := model.RemoveAttributeViewBlock(ids, avID); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadAttrViewEntry(avID)\n\t\tfmt.Println(\"ok\")\n\t\treturn nil\n\t},","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/cli/cmd/database.go#L270-L306","documentation":"Thrown by `database remove` (item remove) when `--av` or `--ids` is empty. Removing rows requires the database ID and a comma-separated list of item IDs (row IDs) passed to `model.RemoveAttributeViewBlock`. Both are mandatory; the command then splits `--ids` on commas and trims each entry.","triggerScenarios":"Running `siyuan database remove --av <id>` without `--ids`, or omitting both.","commonSituations":"Not distinguishing item/row IDs from block IDs, or supplying a single ID where the command expects a comma list.","solutions":["List rows with `siyuan database render --av <id>` to obtain item IDs","Pass both: `siyuan database remove --av <avID> --ids <itemID1>,<itemID2>`","Use `--dry-run` to preview how many rows will be removed"],"exampleFix":"// before\nsiyuan database remove --av 20240101000000-av12345\n\n// after\nsiyuan database remove --av 20240101000000-av12345 --ids 20240101000000-row1,20240101000000-row2","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(avID) == \"\" || strings.TrimSpace(idsStr) == \"\" {\n    log.Fatal(\"--av and --ids are required\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Obtain item/row IDs from database render before removing","Use --dry-run to confirm the count of rows targeted for deletion"],"tags":["cli","database","attribute-view","row","flag-validation","argument-required"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}