{"record":{"id":"34ce6e6fee957469","repo":"hasura/graphql-engine","slug":"cannot-export-metadata-from-server-w","errorCode":null,"errorMessage":"cannot export metadata from server: %w","messagePattern":"cannot export metadata from server: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/scripts_update_config_v2.go","lineNumber":447,"sourceCode":"\t\t\t}\n\n\t\t\tdefer func() {\n\t\t\t\tif err != nil {\n\t\t\t\t\tos.RemoveAll(ec.MetadataDir)\n\t\t\t\t}\n\t\t\t}()\n\t\t\t// set codegen to nil, so that it is not exported in yaml\n\t\t\tec.Config.ActionConfig.Codegen = nil\n\t\t\t// run metadata export\n\t\t\tec.Spin(\"Exporting metadata...\")\n\n\t\t\tvar files map[string][]byte\n\n\t\t\tmdHandler := projectmetadata.NewHandlerFromEC(ec)\n\n\t\t\tfiles, err = mdHandler.ExportMetadata()\n\t\t\tif err != nil {\n\t\t\t\treturn errors.E(op, fmt.Errorf(\"cannot export metadata from server: %w\", err))\n\t\t\t}\n\n\t\t\tec.Spin(\"Writing metadata...\")\n\n\t\t\terr = mdHandler.WriteMetadata(files)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.E(op, fmt.Errorf(\"cannot write metadata: %w\", err))\n\t\t\t}\n\n\t\t\tec.Spin(\"Writing new config file...\")\n\t\t\t// Read the config from config.yaml\n\t\t\tcfgByt, err := os.ReadFile(ec.ConfigFile)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.E(op, fmt.Errorf(\"cannot read config file: %w\", err))\n\t\t\t}\n\n\t\t\tvar cfg cli.Config\n","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/scripts_update_config_v2.go#L429-L465","documentation":"During the v2 upgrade the CLI exports metadata from the running server via projectmetadata.NewHandlerFromEC(ec).ExportMetadata(). This fails when the server API call errors: bad endpoint, auth failure, or server unable to reach its own metadata database.","triggerScenarios":"update-project-v2 with --endpoint pointing to a dead/unreachable server, wrong --admin-secret, TLS mismatch, or a Hasura server whose metadata DB is down.","commonSituations":"Server container stopped before the CLI step; admin secret rotated; self-signed cert without --insecure-skip-verify; server version too old to answer the export query.","solutions":["Confirm the server is up: curl $ENDPOINT/healthz","Pass the correct --endpoint and --admin-secret","Restart the Hasura server if its metadata DB is unhealthy","Re-run the update command once export succeeds manually via metadata API"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify server reachable and authed before export\nresp, err := http.Get(endpoint + \"/healthz\")\nif err != nil || resp.StatusCode != 200 { log.Fatal(\"server not ready\") }","typeGuard":null,"tryCatchPattern":"if err := cmd.Execute(); err != nil {\n    if strings.Contains(err.Error(), \"cannot export metadata from server\") {\n        // check endpoint/admin-secret, restart server, retry\n    }\n}","preventionTips":["Health-check the server before running the upgrade script","Pass --admin-secret explicitly rather than relying on env","Keep server and CLI versions compatible"],"tags":["network","metadata","hasura-cli","auth"],"backgroundTag":"metadata-export-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}