siyuan-note/siyuan · error
--av, --key, --item and --value are required
Error message
--av, --key, --item and --value are required
What it means
The `database update` cobra subcommand requires four flags to be non-empty before it can update an Attribute View cell. The RunE handler reads --av, --key, --item, and --value via cmd.Flags().GetString and rejects the invocation if any of the four is the empty string. This is an argv-level guard that fires before any model.UpdateAttributeViewCell call, so the kernel never touches the database when a flag is missing.
Source
Thrown at kernel/cli/cmd/database.go:318
if err := model.RemoveAttributeViewBlock(ids, avID); err != nil {
return err
}
model.AppendPushReloadAttrViewEntry(avID)
fmt.Println("ok")
return nil
},
}
var databaseItemUpdateCmd = &cobra.Command{
Use: "update --av <avID> --key <keyID> --item <itemID> --value <json>",
Short: "Update a cell value",
RunE: func(cmd *cobra.Command, args []string) error {
avID, _ := cmd.Flags().GetString("av")
keyID, _ := cmd.Flags().GetString("key")
itemID, _ := cmd.Flags().GetString("item")
valueStr, _ := cmd.Flags().GetString("value")
if avID == "" || keyID == "" || itemID == "" || valueStr == "" {
return fmt.Errorf("--av, --key, --item and --value are required")
}
var valueData map[string]any
if err := json.Unmarshal([]byte(valueStr), &valueData); err != nil {
return fmt.Errorf("invalid JSON: %s", err)
}
if dryRun {
fmt.Printf("[dry-run] Would update cell in database %s: key=%s item=%s\n", avID, keyID, itemID)
return nil
}
if _, err := model.UpdateAttributeViewCell(nil, avID, keyID, itemID, valueData); err != nil {
return err
}
model.AppendPushReloadAttrViewEntry(avID)
fmt.Println("ok")
return nil
},View on GitHub (pinned to 251596fc0d)
Solutions
- Re-run the command supplying all four flags: `database update --av <avID> --key <keyID> --item <itemID> --value '<json>'`.
- Confirm the exact flag names with `siyuan database update --help`; the Use string lists the canonical names.
- If scripting, guard each variable before invoking: abort with a clear message when any of avID/keyID/itemID/valueStr is empty.
- Remember --value must be present even to clear a cell — pass an explicit empty-object payload the model accepts rather than omitting the flag.
Example fix
// before
siyuan database update --av 20240101000000-abc --key k1 --item i1
// after
siyuan database update --av 20240101000000-abc --key k1 --item i1 --value '{"text":"hello"}' Defensive patterns
Strategy: validation
Validate before calling
# shell: assert all four flags before invoking
[ -n "$AV" ] && [ -n "$KEY" ] && [ -n "$ITEM" ] && [ -n "$VALUE" ] || { echo 'missing --av/--key/--item/--value' >&2; exit 2; }
siyuan database update --av "$AV" --key "$KEY" --item "$ITEM" --value "$VALUE" Type guard
// Go (programmatic caller of the RunE equivalent): guard before calling model.UpdateAttributeViewCell
func hasAllUpdateInputs(avID, keyID, itemID, valueStr string) bool {
return avID != "" && keyID != "" && itemID != "" && valueStr != ""
} Try / catch
# CLI callers propagate the non-zero exit; inspect stderr if ! siyuan database update --av "$AV" --key "$KEY" --item "$ITEM" --value "$VALUE"; then echo "update failed; check flags" >&2 exit 1 fi
Prevention
- Define a shell wrapper function that requires all four variables and exits early.
- Use `set -u` so referencing an unset variable aborts the script.
- Pin the canonical flag set with a usage string in your runbook.
When it happens
Trigger: Invoking `siyuan database update` (or the long form) with any of --av <avID>, --key <keyID>, --item <itemID>, or --value <json> omitted, left empty (e.g. `--av ""`), or misspelled so the flag is never registered. It also fires if the flags are entirely absent because the user expected positional arguments.
Common situations: Copy-pasting a command template and forgetting to fill one placeholder; assuming --value is optional for clearing a cell; mistyping `--item` as `--itemid`; running the command interactively and pressing enter on an empty prompt; scripting the call and passing an unset shell variable that expands to empty.
Related errors
- --av is required
- --av, --name and --type are required
- --av and --key are required
- --block is required for non-detached rows
- --av and --ids are required
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/632fe73e00a38e69.
Report an issue: GitHub.