siyuan-note/siyuan · error
--ids is required
Error message
--ids is required
What it means
Thrown by the `block batch-get` cobra subcommand when the `--ids` flag is empty or omitted. The command fetches document info for a comma-separated list of block IDs via `model.GetDocsInfo`, so at least one ID is mandatory. It fails fast before any model call to avoid a pointless empty query.
Source
Thrown at kernel/cli/cmd/block.go:465
}
if "d" == previousBt.Type {
return fmt.Errorf("document block [%s] cannot be used as a previous sibling; use it as --parent instead", previousID)
}
return nil
}
if err := treenode.CheckListItemNesting(parentID, id); err != nil {
return err
}
return treenode.CheckContainerParent(parentID)
}
var blockBatchGetCmd = &cobra.Command{
Use: "batch-get --ids id1,id2,...",
Short: "Batch get block info",
RunE: func(cmd *cobra.Command, args []string) error {
idsStr, _ := cmd.Flags().GetString("ids")
if idsStr == "" {
return fmt.Errorf("--ids is required")
}
ids := splitIDs(idsStr)
if len(ids) == 0 {
return fmt.Errorf("no valid IDs provided")
}
infos := model.GetDocsInfo(ids, false, false)
switch outputFormat {
case "json":
data, _ := json.MarshalIndent(infos, "", " ")
fmt.Println(string(data))
default:
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
fmt.Fprintln(w, "ID\tNAME\tROOTID\tREFCOUNT")
for _, info := range infos {
fmt.Fprintf(w, "%s\t%s\t%s\t%d\n", info.ID, info.Name, info.RootID, info.RefCount)
}
for _, id := range ids {
found := falseView on GitHub (pinned to 251596fc0d)
Solutions
- Pass a non-empty comma-separated ID list: `siyuan block batch-get --ids 20240101000000-abc1234,20240101000000-def5678`
- Verify the IDs exist with `siyuan block get --id <id>` before batching
- Check the flag name spelling — it is `--ids` (plural), not `--id`
Example fix
// before siyuan block batch-get --ids // after siyuan block batch-get --ids 20240101000000-abc1234,20240101000000-def5678
Defensive patterns
Strategy: validation
Validate before calling
idsFlag := "" // value to pass as --ids
if strings.TrimSpace(idsFlag) == "" {
log.Fatal("--ids must be a non-empty comma-separated list")
} Prevention
- Wrap CLI invocations in a helper that pre-validates required flags before exec
- Always quote the --ids value to prevent shell word-splitting
- Generate IDs from a trusted source (block get / SQL) rather than hand-typing
When it happens
Trigger: Running `siyuan block batch-get` with no `--ids` flag, or `--ids ""` (empty string), or `--ids` pointing to an unset shell variable that expands to nothing.
Common situations: Typo in the flag name (`--id` instead of `--ids`), copy-pasting a command template and forgetting to substitute the real IDs, or a shell quoting bug that strips the value.
Related errors
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/9ed5148b28c681f2.
Report an issue: GitHub.