{"record":{"id":"f7004ac66e5bd4c0","repo":"hasura/graphql-engine","slug":"failed-to-clear-metadata-w","errorCode":null,"errorMessage":"failed to clear metadata: %w","messagePattern":"failed to clear metadata: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/metadata_clear.go","lineNumber":44,"sourceCode":"  hasura metadata clear --admin-secret \"<admin-secret>\"\n\n  # Clear metadata on a different Hasura instance:\n  hasura metadata clear --endpoint \"<endpoint>\"`,\n\t\tSilenceUsage: true,\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\top := genOpName(cmd, \"RunE\")\n\t\t\tif cmd.CalledAs() == \"reset\" {\n\t\t\t\topts.EC.Logger.Warn(\n\t\t\t\t\t\"metadata reset command is deprecated, use metadata clear instead\",\n\t\t\t\t)\n\t\t\t}\n\n\t\t\topts.EC.Spin(\"Clearing metadata...\")\n\t\t\terr := opts.Run()\n\t\t\topts.EC.Spinner.Stop()\n\n\t\t\tif err != nil {\n\t\t\t\treturn errors.E(op, fmt.Errorf(\"failed to clear metadata: %w\", err))\n\t\t\t}\n\n\t\t\topts.EC.Logger.Info(\"Metadata cleared\")\n\n\t\t\treturn nil\n\t\t},\n\t}\n\n\treturn metadataResetCmd\n}\n\ntype MetadataClearOptions struct {\n\tEC *cli.ExecutionContext\n}\n\nfunc (o *MetadataClearOptions) Run() error {\n\tvar (\n\t\top  errors.Op = \"commands.MetadataClearOptions.Run\"","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/metadata_clear.go#L26-L62","documentation":"This error wraps any failure from the metadata clear Run operation after the 'Clearing metadata...' spinner stops. The wrapped error is the real diagnostic — typically an HTTP/API failure talking to the Hasura server's clear_metadata endpoint. The CLI has already successfully built the execution context and config at this point.","triggerScenarios":"Running `hasura metadata clear` when the request to the server fails: wrong or missing --endpoint/--admin-secret, server unreachable, TLS issues, or the server returning an error for the clear_metadata operation.","commonSituations":"Admin secret mismatch (401/403), pointing at a stale endpoint after server migration, local dev server not running, self-signed certs in HTTPS setups, or CLI-server version skew where the metadata API shape differs.","solutions":["Verify the endpoint and admin secret: hasura metadata clear --endpoint <url> --admin-secret <secret>","Check the server is reachable: curl the /healthz endpoint of your Hasura server","Inspect the wrapped error for the HTTP status/body to distinguish auth (401) from connectivity failures","Update the CLI to match your server version: hasura update-cli or reinstall"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Shell: check server health before clearing\nhasura metadata clear --dry-run 2>/dev/null || true\ncurl -fsS \"$ENDPOINT/healthz\" || { echo 'server down'; exit 1; }","typeGuard":null,"tryCatchPattern":"// Go: retry transient server errors\nvar err error\nfor i := 0; i < 3; i++ {\n  if err = opts.Run(); err == nil { break }\n  time.Sleep(time.Duration(i+1) * time.Second)\n}","preventionTips":["Pass --endpoint and --admin-secret explicitly in scripts","Health-check the server before destructive metadata operations"],"tags":["metadata-clear","hasura-api","network","auth"],"backgroundTag":"hasura-api-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}