{"record":{"id":"7c448898aee1cb45","repo":"hasura/graphql-engine","slug":"cannot-build-s-from-project-w","errorCode":null,"errorMessage":"cannot build %s from project: %w","messagePattern":"cannot build (.+?) from project: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/projectmetadata/handler.go","lineNumber":177,"sourceCode":"\t\top       internalerrors.Op = \"projectmetadata.Handler.buildMetadataMap\"\n\t\tmetadata                   = map[string]any{}\n\t)\n\n\tfor _, object := range h.objects {\n\t\tobjectMetadata, err := object.Build()\n\t\tif err != nil {\n\t\t\tif errors.Is(err, metadataobject.ErrMetadataFileNotFound) {\n\t\t\t\th.logger.Debugf(\n\t\t\t\t\t\"metadata file for %s was not found, assuming an empty file\",\n\t\t\t\t\tobject.Key(),\n\t\t\t\t)\n\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\treturn nil, internalerrors.E(\n\t\t\t\top,\n\t\t\t\tfmt.Errorf(\"cannot build %s from project: %w\", object.Key(), err),\n\t\t\t)\n\t\t}\n\n\t\tmaps.Copy(metadata, objectMetadata)\n\t}\n\n\treturn metadata, nil\n}\n\n// buildMetadata is a private function because we don't intend consumers of this package\n// to use the returned result (metadataobject.Metadata) directly because they may assume that they can use\n// json.Marshal to get JSON representation of the built metadata. But this assumption will not hold true because\n// the underlying types might have instances of yaml.Node which is not friendly with a json.Marshal and can produce\n// unexpected results. Rather to get a JSON / YAML form of built metadata make use of Handler.BuildYAMLMetadata and\n// Handler.BuildJSONMetadata helper functions.\nfunc (h *Handler) buildMetadata() (*Metadata, error) {\n\tvar op internalerrors.Op = \"projectmetadata.Handler.buildMetadata\"\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/projectmetadata/handler.go#L159-L195","documentation":"Thrown by projectmetadata buildMetadataMap when a metadata object cannot be reconstructed from the files on disk in the project's metadata directory. The %s is the object's Key() and %w the underlying build error — usually unmarshaling an invalid YAML/JSON metadata file for that subsystem.","triggerScenarios":"Calling buildMetadata (hasura metadata apply/EXPORT flows) when any file under metadata/ contains invalid YAML/JSON, references an entity that doesn't parse, or the file layout doesn't match the expected structure for that metadata kind.","commonSituations":"Hand-edited metadata files with syntax errors, files written by a different (older/newer) CLI version with a different schema, merge conflicts left unresolved in metadata/*.yaml.","solutions":["Validate every file under metadata/ with a YAML/JSON linter and fix syntax errors","Check the wrapped error to identify the offending file (the object key tells you which subsystem)","Re-export metadata from the server into a fresh directory and diff against your project files"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func validateMetadataDir(dir string) error {\n\treturn filepath.WalkDir(dir, func(p string, d fs.DirEntry, err error) error {\n\t\tif err != nil || d.IsDir() || (!strings.HasSuffix(p, \".yaml\") && !strings.HasSuffix(p, \".json\")) {\n\t\t\treturn err\n\t\t}\n\t\tdata, rerr := os.ReadFile(p)\n\t\tif rerr != nil {\n\t\t\treturn rerr\n\t\t}\n\t\tif strings.HasSuffix(p, \".json\") {\n\t\t\treturn json.Unmarshal(data, &struct{}{})\n\t\t}\n\t\treturn yaml.Unmarshal(data, &struct{}{})\n\t})\n}","typeGuard":null,"tryCatchPattern":"if _, err := handler.BuildMetadata(); err != nil {\n\tif strings.Contains(err.Error(), \"cannot build\") {\n\t\t// identify the subsystem key and validate its files\n\t}\n}","preventionTips":["Lint metadata/ files in CI","Resolve git merge conflicts fully before applying metadata"],"tags":["go","metadata","yaml","unmarshal","hasura-cli"],"backgroundTag":"metadata-validation-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}