siyuan-note/siyuan · error
no valid IDs provided
Error message
no valid IDs provided
What it means
Thrown by `block batch-get` when the `--ids` string is non-empty but `splitIDs` (block.go:532) yields zero valid tokens. `splitIDs` splits on commas, trims whitespace, and drops empty parts — so input like `","`, `" , , "`, or `" "` produces an empty slice. This is a second-level guard catching malformed but non-empty input.
Source
Thrown at kernel/cli/cmd/block.go:469
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 251596fc0d)
Solutions
- Inspect the exact `--ids` value the shell receives; ensure at least one real ID token survives splitting
- Build the ID list programmatically and filter empties before passing: join only non-empty values
- Quote the argument properly so stray spaces/commas are not introduced
Example fix
// before siyuan block batch-get --ids ",," // after siyuan block batch-get --ids 20240101000000-abc1234
Defensive patterns
Strategy: validation
Validate before calling
parts := strings.Split(idsFlag, ",")
valid := []string{}
for _, p := range parts {
if t := strings.TrimSpace(p); t != "" {
valid = append(valid, t)
}
}
if len(valid) == 0 {
log.Fatal("--ids produced no valid IDs after trimming")
} Prevention
- Filter empties when building the ID list in your script before joining
- Avoid trailing commas in generated lists
- Unit-test list assembly against edge inputs like ",," and " "
When it happens
Trigger: Passing `--ids ,,,`, `--ids " "`, or `--ids " , , , "` — strings that are not literally empty but contain only separators/whitespace.
Common situations: Trailing-comma lists from a script (`"id1,id2,"` is fine, but `","` is not), trailing-comma lists, or copy-paste artifacts that leave only punctuation.
Related errors
- --ids is required
- --id is required
- document not found or empty
- --parent is required
- --id and --parent are required
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/a0d7fef59537b49d.
Report an issue: GitHub.