{"record":{"id":"bf2533fb769171c5","repo":"siyuan-note/siyuan","slug":"av-is-required","errorCode":null,"errorMessage":"--av is required","messagePattern":"--av is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/cli/cmd/database.go","lineNumber":61,"sourceCode":"\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tresults := model.SearchAttributeView(args[0], nil, \"\", \"\")\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\treturn printJSON(results)\n\t\tdefault:\n\t\t\tprintAvSearchResults(results)\n\t\t}\n\t\treturn nil\n\t},\n}\n\nvar databaseGetCmd = &cobra.Command{\n\tUse:   \"get --av <avID>\",\n\tShort: \"Get database content\",\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tavID, _ := cmd.Flags().GetString(\"av\")\n\t\tif avID == \"\" {\n\t\t\treturn fmt.Errorf(\"--av is required\")\n\t\t}\n\t\tattrView := model.GetAttributeView(avID)\n\t\tif attrView == nil {\n\t\t\treturn fmt.Errorf(\"database not found: %s\", avID)\n\t\t}\n\t\tswitch outputFormat {\n\t\tcase \"json\":\n\t\t\treturn printJSON(model.NewAttributeViewMetadata(attrView))\n\t\tdefault:\n\t\t\tprintDatabaseMetadata(attrView)\n\t\t}\n\t\treturn nil\n\t},\n}\n\nvar databaseRenderCmd = &cobra.Command{\n\tUse:   \"render --av <avID>\",\n\tShort: \"Render database data\",","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/cli/cmd/database.go#L43-L79","documentation":"The `database get` subcommand requires `--av` to identify the attribute view (database) to read. When the flag is empty, RunE returns this error before calling model.GetAttributeView. It distinguishes a missing argument from a not-found database (error 504).","triggerScenarios":"Running `siyuan database get` without `--av`, or with `--av \"\"`.","commonSituations":"Copy-pasting commands and dropping the flag; extracting av IDs from URLs and ending up with an empty variable in shell scripts; typos like `--attr-view`.","solutions":["Pass `--av <avID>` with the database ID from the block's `custom-av` attribute or the database panel","Confirm flag spelling is exactly `--av`","Echo the av variable in scripts to confirm it is non-empty before invoking"],"exampleFix":"// before\nsiyuan database get\n// after\nsiyuan database get --av 20240101120000-avxyz","handlingStrategy":"validation","validationCode":"if [ -z \"$AV_ID\" ]; then echo \"--av is required\"; exit 1; fi\nsiyuan database get --av \"$AV_ID\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Extract the av ID (not the block ID) from the database block","Guard av variables against emptiness in scripts","Use `siyuan database keys`/query to verify the ID resolves"],"tags":["cli","validation","database"],"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"}