{"record":{"id":"dd793a828c15b6fd","repo":"hasura/graphql-engine","slug":"metadata-diff-only-works-with-folder-but-got-file","errorCode":null,"errorMessage":"metadata diff only works with folder but got file %s","messagePattern":"metadata diff only works with folder but got file (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/metadata_diff.go","lineNumber":286,"sourceCode":"\t\t\tfmt.Fprintf(to, \"%s\\n\", ansi.Color(text, \"red\"))\n\t\tcase difflib.Common:\n\t\t\tfmt.Fprintf(to, \"%s\\n\", text)\n\t\t}\n\t}\n}\n\nfunc checkDir(path string) error {\n\tvar op errors.Op = \"commands.checkDir\"\n\n\tfile, err := os.Stat(path)\n\tif err != nil {\n\t\treturn errors.E(op, err)\n\t}\n\n\tif !file.IsDir() {\n\t\treturn errors.E(\n\t\t\top,\n\t\t\tfmt.Errorf(\"metadata diff only works with folder but got file %s\", path),\n\t\t)\n\t}\n\n\treturn nil\n}\n\nfunc convertYamlToJsonWithIndent(yamlByt []byte) ([]byte, error) {\n\tvar op errors.Op = \"commands.convertYamlToJsonWithIndent\"\n\n\tjsonByt, err := metadatautil.YAMLToJSON(yamlByt)\n\tif err != nil {\n\t\treturn nil, errors.E(op, fmt.Errorf(\"cannot convert yaml to json: %w\", err))\n\t}\n\n\tvar jsonBuf bytes.Buffer\n\n\terr = json.Indent(&jsonBuf, jsonByt, \"\", \"  \")\n\tif err != nil {","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/metadata_diff.go#L268-L304","documentation":"checkDir validates that a path passed to metadata diff is a directory; if os.Stat succeeds but the path is a regular file, this error is returned. The diff command needs a directory containing multiple metadata files, not a single file.","triggerScenarios":"Passing a file path where a directory is expected: `hasura metadata diff ./metadata/tables.yaml ./other/metadata` — the first argument must be a directory. Also triggered by symlink targets that resolve to files.","commonSituations":"Assuming diff takes individual metadata files like tables.yaml instead of the whole metadata directory, tab-completing to a file inside the directory, or scripts hardcoding a file path.","solutions":["Pass the metadata directories, not individual files: hasura metadata diff ./metadata ./other-project/metadata","Verify with ls -d <path> that each argument is a directory","If comparing a single file, diff it manually or restructure to compare whole directories"],"exampleFix":"# before\nhasura metadata diff metadata/tables.yaml other/metadata/tables.yaml\n# after\nhasura metadata diff metadata other/metadata","handlingStrategy":"validation","validationCode":"# Shell: ensure both args are directories\nfor d in \"$1\" \"$2\"; do [ -d \"$d\" ] || { echo \"not a directory: $d\"; exit 1; }; done\nhasura metadata diff \"$1\" \"$2\"","typeGuard":"// Go\nfunc isDirectory(path string) bool {\n  info, err := os.Stat(path)\n  return err == nil && info.IsDir()\n}","tryCatchPattern":null,"preventionTips":["Pass metadata directories, never individual files","Beware symlinks that resolve to regular files"],"tags":["filesystem","validation","metadata-diff","cli"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}