{"record":{"id":"a7a71a8cc3370ecd","repo":"hasura/graphql-engine","slug":"reading-local-metadata-w","errorCode":null,"errorMessage":"reading local metadata: %w","messagePattern":"reading local metadata: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/metadata_handlers.go","lineNumber":447,"sourceCode":"\t}\n\n\tvar serverMetadataBytes []byte\n\n\tserverMetadataBytes, err = io.ReadAll(serverMetadata)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"reading server metadata: %w\", err))\n\t}\n\n\tif diffType == DifftypeYAML {\n\t\tserverMetadataBytes, err = metadatautil.JSONToYAML(serverMetadataBytes)\n\t\tif err != nil {\n\t\t\treturn errors.E(op, fmt.Errorf(\"parsing server metadata as yaml: %w\", err))\n\t\t}\n\t}\n\n\tlocalMetadataBytes, err := os.ReadFile(o.EC.MetadataFile)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"reading local metadata: %w\", err))\n\t}\n\n\tif err := printMyersDiff(\n\t\tstring(serverMetadataBytes),\n\t\tstring(localMetadataBytes),\n\t\t\"server\",\n\t\t\"project\",\n\t\to.Output,\n\t\to.DisableColor,\n\t); err != nil {\n\t\treturn errors.E(op, err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":429,"sourceCodeEnd":463,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/metadata_handlers.go#L429-L463","documentation":"`metadata diff` reads the local metadata file (from config) with os.ReadFile to compare it against the server's metadata. This error is a local filesystem failure: the metadata file is missing, unreadable, or the configured path is wrong — it occurs after the server export succeeded.","triggerScenarios":"Running `metadata diff` when the configured metadata file does not exist, lacks read permission, or the path is incorrect/directory — e.g. diffing before ever running `metadata export` in a fresh project.","commonSituations":"Fresh project where metadata file was never exported or is not committed to the repo; config's metadata file path pointing to a stale location; running from the wrong directory so relative paths fail; file owned by another user.","solutions":["Run `metadata export` first to create the local metadata file","Verify the metadata file path in config and that the file exists and is readable from the CLI's working directory","Fix permissions or ownership of the file if needed","If you intended to diff a different file, update the config's metadata file setting rather than passing a path argument (diff takes no arguments)"],"exampleFix":"# before\nhasura metadata diff  # reading local metadata: no such file or directory\n# after\nhasura metadata export  # creates the file, then\nhasura metadata diff","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(ec.MetadataFile); err != nil {\n  return errors.New(\"local metadata file missing — run `metadata export` before diff\")\n}","typeGuard":null,"tryCatchPattern":"if err := diff(o, diffType); err != nil {\n  if strings.Contains(err.Error(), \"reading local metadata\") {\n    // export first or fix the metadata file path in config\n  }\n}","preventionTips":["Always export metadata before the first diff in a project","Commit the metadata file to version control","Verify config's metadata file path on new machines"],"tags":["metadata","diff","filesystem","file-not-found","cli"],"backgroundTag":"file-not-found","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}