{"record":{"id":"31ef06ac8650e1ae","repo":"dgraph-io/dgraph","slug":"incorrect-format-for-specifying-dgraph-secret-foun","errorCode":null,"errorMessage":"incorrect format for specifying Dgraph secret found for comment: `%s`, it should be `# Dgraph.Secret key value`","messagePattern":"incorrect format for specifying Dgraph secret found for comment: `(.+?)`, it should be `# Dgraph\\.Secret key value`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"graphql/schema/schemagen.go","lineNumber":243,"sourceCode":"\t\t\t\t}\n\t\t\t\tvar allowedOrigin string\n\t\t\t\tif err = json.Unmarshal([]byte(parts[2]), &allowedOrigin); err != nil {\n\t\t\t\t\treturn nil, errors.Errorf(\"incorrect format for specifying Dgraph.Allow-Origin\"+\n\t\t\t\t\t\t\" found for comment: `%s`, it should be `# Dgraph.\"+\n\t\t\t\t\t\t\"Allow-Origin \\\"http://example.com\\\"`\", text)\n\t\t\t\t}\n\t\t\t\tschMetaInfo.allowedCorsOrigins[allowedOrigin] = true\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif !strings.HasPrefix(header, \"Dgraph.Secret\") {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tparts := strings.Fields(text)\n\t\t\tconst doubleQuotesCode = 34\n\n\t\t\tif len(parts) < 4 {\n\t\t\t\treturn nil, errors.Errorf(\"incorrect format for specifying Dgraph secret found for \"+\n\t\t\t\t\t\"comment: `%s`, it should be `# Dgraph.Secret key value`\", text)\n\t\t\t}\n\t\t\tval := strings.Join(parts[3:], \" \")\n\t\t\tif strings.Count(val, `\"`) != 2 || val[0] != doubleQuotesCode || val[len(val)-1] != doubleQuotesCode {\n\t\t\t\treturn nil, errors.Errorf(\"incorrect format for specifying Dgraph secret found for \"+\n\t\t\t\t\t\"comment: `%s`, it should be `# Dgraph.Secret key value`\", text)\n\t\t\t}\n\n\t\t\tval = strings.Trim(val, `\"`)\n\t\t\tkey := strings.Trim(parts[2], `\"`)\n\t\t\t// lets obfuscate the value of the secrets from here on.\n\t\t\tschMetaInfo.secrets[key] = x.Sensitive(val)\n\t\t}\n\t}\n\n\tif err = scanner.Err(); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"while trying to parse secrets from schema file\")\n\t}","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/graphql/schema/schemagen.go#L225-L261","documentation":"parseMetaInfo reads `# Dgraph.Secret key value` comments from the GraphQL schema file. This error is thrown when a Dgraph.Secret comment line has fewer than 4 whitespace-separated fields (i.e. missing the key and/or value after `# Dgraph.Secret`), so the secret cannot be parsed.","triggerScenarios":"Calling NewHandler with a schema containing a comment like `# Dgraph.Secret` or `# Dgraph.Secret apiKey` with no value — strings.Fields(text) yields fewer than 4 tokens.","commonSituations":"Hand-edited schema files where the secret value was deleted or never filled in; copy-paste of the directive comment without the actual key/value; templating that rendered an empty secret.","solutions":["Add both a key and a value to the comment: `# Dgraph.Secret myKey \"myValue\"`","Verify the comment starts with exactly `# Dgraph.Secret` followed by key then value","Quote the value in double quotes if it contains spaces"],"exampleFix":"// before\n# Dgraph.Secret apiKey\n// after\n# Dgraph.Secret apiKey \"my-secret-value\"","handlingStrategy":"validation","validationCode":"func validSecretComment(line string) bool {\n\tparts := strings.Fields(line)\n\treturn len(parts) >= 4 && parts[1] == \"Dgraph.Secret\"\n}\n// validate each schema line before passing the schema to NewHandler","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint schema comments so every `# Dgraph.Secret` line has key and quoted value","Use a schema template with placeholders instead of editing comments by hand","Run schema creation in CI to catch malformed secret lines before deploy"],"tags":["graphql","schema","configuration","secrets"],"backgroundTag":"dgraph-secret-format","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}