siyuan-note/siyuan · error
--id is required
Error message
--id is required
What it means
The `attr get` subcommand requires the --id flag (block ID) but it was empty or omitted. Thrown by attrGetCmd.RunE at kernel/cli/cmd/attr.go:42-44. The ID is then passed to sql.GetBlockAttrs to read custom block attributes.
Source
Thrown at kernel/cli/cmd/attr.go:44
"github.com/siyuan-note/siyuan/kernel/model"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/spf13/cobra"
)
var attrCmd = &cobra.Command{
Use: "attr",
Short: "Manage block attributes",
}
var attrGetCmd = &cobra.Command{
Use: "get --id <id>",
Short: "Get block attributes",
RunE: func(cmd *cobra.Command, args []string) error {
id, _ := cmd.Flags().GetString("id")
if id == "" {
return fmt.Errorf("--id is required")
}
attrs := sql.GetBlockAttrs(id)
switch outputFormat {
case "json":
data, _ := json.MarshalIndent(attrs, "", " ")
fmt.Println(string(data))
default:
printAttrTable(attrs)
}
return nil
},
}
var attrSetCmd = &cobra.Command{
Use: "set --id <id> --attr name=value",
Short: "Set block attributes",
Long: `Set custom attributes on a block.View on GitHub (pinned to 251596fc0d)
Solutions
- Pass the target block ID: `attr get --id 20260605100657-v080a4j`
- If scripting, ensure the ID variable is non-empty before invoking
- Use `attr get --help` to confirm the flag
Example fix
# before siyuan-kernel attr get # after siyuan-kernel attr get --id 20260605100657-v080a4j
Defensive patterns
Strategy: validation
Validate before calling
if id == "" { return errors.New("--id is required") }
// Or: attrGetCmd.MarkFlagRequired("id") Prevention
- Mark --id required via cobra
- In scripts, assert the block ID variable is non-empty before invoking
- Copy the full block ID including the timestamp-prefix and 6-char suffix
When it happens
Trigger: Running `siyuan-kernel attr get` without --id, or passing an empty --id value.
Common situations: The user forgot the flag; a script variable holding the block ID was empty; the block ID was copied incorrectly.
Related errors
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/3eaee8aea61913ec.
Report an issue: GitHub.