siyuan-note/siyuan · error
--id is required
Error message
--id is required
What it means
Returned by the `outline get` subcommand when --id is empty. The document outline command requires a target document/block ID to build its heading tree.
Source
Thrown at kernel/cli/cmd/outline.go:40
"strings"
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/spf13/cobra"
)
var outlineCmd = &cobra.Command{
Use: "outline",
Short: "Document outline (heading tree)",
}
var outlineGetCmd = &cobra.Command{
Use: "get --id <id>",
Short: "Get document outline",
RunE: func(cmd *cobra.Command, args []string) error {
id, _ := cmd.Flags().GetString("id")
if id == "" {
return fmt.Errorf("--id is required")
}
paths, err := model.Outline(id, false)
if err != nil {
return err
}
if len(paths) == 0 {
return fmt.Errorf("document not found or has no headings")
}
switch outputFormat {
case "json":
data, _ := json.MarshalIndent(paths, "", " ")
fmt.Println(string(data))
default:
var sb strings.Builder
sb.WriteString(fmt.Sprintf("Document outline (%d headings):\n\n", countOutlineHeadings(paths)))
for _, p := range paths {
writeOutlinePath(&sb, p, 0)
}View on GitHub (pinned to 251596fc0d)
Solutions
- Pass a valid document ID: `outline get --id <doc-id>`.
- Obtain the ID from the editor URL or `block` commands if unsure.
Example fix
# before siyuan outline get # after siyuan outline get --id 202406011200-abcdef
Defensive patterns
Strategy: validation
Validate before calling
[ -n "$DOC_ID" ] || { echo 'outline get requires --id'; exit 1; }
siyuan outline get --id "$DOC_ID" Type guard
n/a (CLI flag validation)
Try / catch
n/a
Prevention
- Use a document root ID, not a child block ID, for outline queries.
- Source IDs from the editor URL or block inspection commands.
When it happens
Trigger: Running `outline get` with no --id flag or an empty value, before model.Outline is called.
Common situations: Forgetting the flag, assuming a default document, or a script that failed to resolve the document ID.
Related errors
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/c3ab4886971fcace.
Report an issue: GitHub.