siyuan-note/siyuan · error
no valid IDs provided
Error message
no valid IDs provided
What it means
The --ids flag was provided to `block batch-get` but after splitting on commas no valid (non-empty) IDs remained. splitIDs trims and filters empty entries, so input consisting only of commas or whitespace yields this error (kernel/cli/cmd/block.go:485).
Solutions
- Provide at least one real block ID: --ids 20240101120000-abc
- Separate multiple IDs with commas only, no semicolons or spaces
- Guard the calling script: abort when the upstream ID list is empty before invoking the CLI
Example fix
// before siyuan block batch-get --ids "a; b; c" // after siyuan block batch-get --ids "20240101120000-a,20240101120000-b,20240101120000-c"
Defensive patterns
Strategy: validation
Validate before calling
ids=$(echo "$RAW" | tr ',' '\n' | sed 's/[[:space:]]//g' | grep -v '^$') if [ -z "$ids" ]; then echo "no valid IDs" >&2; exit 1; fi siyuan block batch-get --ids "$(echo $ids | paste -sd, -)"
Prevention
- Sanitize ID lists: strip whitespace and drop empty entries before invoking
- Use ASCII commas only as separators
- Fail fast in scripts when an upstream query yields no IDs
When it happens
Trigger: Running `batch-get --ids ",,,"` or `--ids " "`; a script building the ID list from an empty query result; whitespace-only or malformed separator characters (e.g. semicolons or newlines) leaving zero parseable IDs.
Common situations: Automating the CLI where an upstream step returned no blocks; pasting IDs separated by semicolons or spaces instead of commas; Windows line endings contaminating the ID list.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- --ids is required
- AI editor input is empty
- appearance files not found at
- asset data is empty
- at least one asset path or mapping is required
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/a0d7fef59537b49d.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/cli/cmd/block.go:485
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 := false
for _, info := range infos {
if info.ID == id {
found = true
breakView on GitHub (pinned to 9f775e8a12)