siyuan-note/siyuan · error
--av and --ids are required
Error message
--av and --ids are required
What it means
The `siyuan database item remove` command requires both the target attribute-view ID (`--av`) and a comma-separated list of row IDs (`--ids`). RunE validates both at once and returns this combined error when either is empty. The ids are later split on commas and trimmed, but empty overall input is rejected first.
Solutions
- Pass both flags: `siyuan database item remove --av <avID> --ids <id1,id2,...>`
- Obtain row IDs from a previous database query or by inspecting the attribute view before constructing the command
- Guard the script so it aborts when AV_ID or ROW_IDS is unset rather than invoking with empty values
Example fix
// before siyuan database item remove --ids "$ROW_IDS" // after siyuan database item remove --av "$AV_ID" --ids "$ROW_IDS"
Defensive patterns
Strategy: validation
Validate before calling
if [ -z "$AV_ID" ] || [ -z "$ROW_IDS" ]; then echo "both --av and --ids are required" >&2; exit 1 fi
Prevention
- Query row IDs immediately before removal so the list is fresh and non-empty
- Assert both variables non-empty before invoking the CLI
- Prefer dry-run (`--dry-run`) to confirm flags resolved before the real removal
When it happens
Trigger: Running `siyuan database item remove` with `--av` omitted, with `--ids` omitted, or both. Only overall-empty idsStr is rejected here; an ids string of only commas/whitespace passes this check.
Common situations: Building the remove command in a script where the ids variable was never populated from a previous query; forgetting to pass --av while iterating row IDs; deleting a command line's flags during manual testing.
Understand the failure class
Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.
Related errors
- --av, --key, --item and --value are required
- --block is required for non-detached rows
- --av and --key are required
- --av is required
- --av, --name and --type are required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/980d41efe04bc59e.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/database.go:293
srcs := []map[string]any{src}
if err := model.AddAttributeViewBlock(nil, srcs, avID, "", viewID, groupID, previousID, ignoreFill); err != nil {
return err
}
model.AppendPushReloadAttrViewEntry(avID)
fmt.Println("ok")
return nil
},
}
var databaseItemRemoveCmd = &cobra.Command{
Use: "remove --av <avID> --ids <id1,id2,...>",
Short: "Remove rows from database",
RunE: func(cmd *cobra.Command, args []string) error {
avID, _ := cmd.Flags().GetString("av")
idsStr, _ := cmd.Flags().GetString("ids")
if avID == "" || idsStr == "" {
return fmt.Errorf("--av and --ids are required")
}
ids := strings.Split(idsStr, ",")
for i := range ids {
ids[i] = strings.TrimSpace(ids[i])
}
if dryRun {
fmt.Printf("[dry-run] Would remove %d row(s) from database %s\n", len(ids), avID)
return nil
}
if err := model.RemoveAttributeViewBlock(ids, avID); err != nil {
return err
}
model.AppendPushReloadAttrViewEntry(avID)
fmt.Println("ok")
return nil
},View on GitHub (pinned to 9f775e8a12)