{"record":{"id":"632fe73e00a38e69","repo":"siyuan-note/siyuan","slug":"av-key-item-and-value-are-required","errorCode":null,"errorMessage":"--av, --key, --item and --value are required","messagePattern":"--av, --key, --item and --value are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/database.go","lineNumber":323,"sourceCode":"\t\tif err := model.RemoveAttributeViewBlock(ids, avID); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadAttrViewEntry(avID)\n\t\tfmt.Println(\"ok\")\n\t\treturn nil\n\t},\n}\n\nvar databaseItemUpdateCmd = &cobra.Command{\n\tUse:   \"update --av <avID> --key <keyID> --item <itemID> --value <json>\",\n\tShort: \"Update a cell value\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tavID, _ := cmd.Flags().GetString(\"av\")\n\t\tkeyID, _ := cmd.Flags().GetString(\"key\")\n\t\titemID, _ := cmd.Flags().GetString(\"item\")\n\t\tvalueStr, _ := cmd.Flags().GetString(\"value\")\n\t\tif avID == \"\" || keyID == \"\" || itemID == \"\" || valueStr == \"\" {\n\t\t\treturn fmt.Errorf(\"--av, --key, --item and --value are required\")\n\t\t}\n\t\tvar valueData map[string]any\n\t\tif err := json.Unmarshal([]byte(valueStr), &valueData); err != nil {\n\t\t\treturn fmt.Errorf(\"invalid JSON: %s\", err)\n\t\t}\n\n\t\tif dryRun {\n\t\t\tfmt.Printf(\"[dry-run] Would update cell in database %s: key=%s item=%s\\n\", avID, keyID, itemID)\n\t\t\treturn nil\n\t\t}\n\n\t\tif _, err := model.UpdateAttributeViewCell(nil, avID, keyID, itemID, valueData); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tmodel.AppendPushReloadAttrViewEntry(avID)\n\t\tfmt.Println(\"ok\")\n\t\treturn nil\n\t},","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/database.go#L305-L341","documentation":"The `siyuan database item update` command requires four flags identifying the cell and its new value: `--av` (attribute-view ID), `--key` (column/key ID), `--item` (row ID), and `--value` (JSON object for the cell value). RunE rejects the invocation with this combined error if any of the four is empty.","triggerScenarios":"Running `siyuan database item update` with any one (or more) of --av, --key, --item, --value missing or empty-string. Partial invocations like only `--av --item` are rejected identically.","commonSituations":"Interactive shell history edits dropping one flag; scripts where the key ID was hardcoded for one database but the script was reused against another; forgetting `--value` when only intending a dry-run; long command lines that visually overflow and a flag gets lost.","solutions":["Supply all four flags: `siyuan database item update --av <avID> --key <keyID> --item <itemID> --value '{...}'`","Find the key (column) ID and row (item) ID from the database structure before updating","Run with `--dry-run` first to confirm the target cell is resolved without writing"],"exampleFix":"// before\nsiyuan database item update --av $AV_ID --item $ROW_ID --value '{\"type\":\"text\",\"text\":\"done\"}'\n// after\nsiyuan database item update --av $AV_ID --key $KEY_ID --item $ROW_ID --value '{\"type\":\"text\",\"text\":\"done\"}'","handlingStrategy":"validation","validationCode":"for v in \"$AV_ID\" \"$KEY_ID\" \"$ITEM_ID\" \"$VALUE\"; do\n  [ -n \"$v\" ] || { echo \"--av, --key, --item, --value all required\" >&2; exit 1; }\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Look up key and item IDs from the database structure rather than hardcoding","Build the update command programmatically from a parameter list to avoid dropped flags","Run with --dry-run first to validate all four inputs resolve"],"tags":["cli","validation","database","missing-flag"],"backgroundTag":"missing-required-flag","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}