{"record":{"id":"89d38417854d9b49","repo":"hasura/graphql-engine","slug":"error-applying-metadata-w","errorCode":null,"errorMessage":"error applying metadata \n%w","messagePattern":"error applying metadata \n%w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/metadata_apply.go","lineNumber":129,"sourceCode":"\tDisallowInconsistencies bool\n}\n\nfunc (o *MetadataApplyOptions) Run() error {\n\tvar op errors.Op = \"commands.MetadataApplyOptions.Run\"\n\n\terr := getMetadataModeHandler(o.EC.MetadataMode).Apply(o)\n\tif err != nil {\n\t\treturn errors.E(op, err)\n\t}\n\n\treturn nil\n}\n\nfunc errorApplyingMetadata(err error) error {\n\tvar op errors.Op = \"commands.errorApplyingMetadata\"\n\t// a helper function to have consistent error messages for errors\n\t// when applying metadata\n\treturn errors.E(op, fmt.Errorf(\"error applying metadata \\n%w\", err))\n}\n","sourceCodeStart":111,"sourceCodeEnd":131,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/metadata_apply.go#L111-L131","documentation":"This is a formatting helper (errorApplyingMetadata) that wraps any failure encountered during `hasura metadata apply` with the message 'error applying metadata'. It carries no failure cause of its own — the meaningful diagnostic is always the wrapped error underneath, typically a server-side metadata validation or API error.","triggerScenarios":"Running `hasura metadata apply` where any step fails: the server rejects the metadata (invalid metadata, inconsistent objects), the apply handler cannot read the metadata directory/files, or a dependent step (e.g. applying data sources) returns an error that gets funneled through this wrapper.","commonSituations":"Metadata files hand-edited and now invalid, applying metadata to a server running an incompatible Hasura version, metadata referencing tables/relationships that don't exist in the database, or wrong admin secret causing auth failures deeper in the chain.","solutions":["Read the wrapped error below the 'error applying metadata' message — the actual cause (server response, validation detail) is there","Validate metadata against the server first with `hasura metadata diff` or the /v1/metadata export+apply dry run to spot inconsistencies","Ensure the metadata directory layout matches what `hasura metadata export` produces","Confirm server compatibility: matching Hasura CLI and server versions, correct --endpoint and --admin-secret"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go: surface the wrapped cause\nif err := metadataApplyHandler.Apply(opts); err != nil {\n  return fmt.Errorf(\"metadata apply failed: %w\", errors.Unwrap(err))\n}","preventionTips":["Run hasura metadata diff before apply to catch inconsistencies","Keep CLI and server versions aligned"],"tags":["metadata-apply","wrapper","validation"],"backgroundTag":"metadata-apply-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}