{"record":{"id":"32d3df12a9bf21e3","repo":"dgraph-io/dgraph","slug":"no-schema-found-after-namespace-got-v","errorCode":null,"errorMessage":"No schema found after namespace. Got: %v","messagePattern":"No schema found after namespace\\. Got: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"schema/parse.go","lineNumber":597,"sourceCode":"}\n\nfunc parseNamespace(it *lex.ItemIterator) (uint64, error) {\n\tnextItems, err := it.Peek(2)\n\tif err != nil {\n\t\treturn 0, errors.Errorf(\"Unable to peek: %v\", err)\n\t}\n\tif nextItems[0].Typ != itemNumber || nextItems[1].Typ != itemRightSquare {\n\t\treturn 0, errors.Errorf(\"Typed oes not match the expected\")\n\t}\n\tns, err := strconv.ParseUint(nextItems[0].Val, 0, 64)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tit.Next()\n\tit.Next()\n\t// We have parsed the namespace. Now move to the next item.\n\tif !it.Next() {\n\t\treturn 0, errors.Errorf(\"No schema found after namespace. Got: %v\", nextItems[0])\n\t}\n\treturn ns, nil\n}\n\n// ParsedSchema represents the parsed schema and type updates.\ntype ParsedSchema struct {\n\tPreds []*pb.SchemaUpdate\n\tTypes []*pb.TypeUpdate\n}\n\nfunc isTypeDeclaration(item lex.Item, it *lex.ItemIterator) bool {\n\tif item.Val != \"type\" {\n\t\treturn false\n\t}\n\n\tnextItems, err := it.Peek(2)\n\tswitch {\n\tcase err != nil || len(nextItems) != 2:","sourceCodeStart":579,"sourceCodeEnd":615,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/schema/parse.go#L579-L615","documentation":"After consuming the namespace tokens, parseNamespace calls it.Next() and, if no further token exists, reports 'No schema found after namespace'. It means the schema ended immediately after the [ns] section with no predicate/type declarations following.","triggerScenarios":"Passing a schema string that consists only of a namespace header, e.g. \"[0x1]\" or \"[0x1]\\n\", to schema.Parse or ParseWithNamespace.","commonSituations":"Generating schema from a template where all predicates were filtered out, leaving only the namespace; empty drop-all-then-modify flows that post a schema with headers but no definitions; truncated multi-line schema files.","solutions":["Include at least one predicate/type definition after the [ns] block, e.g. \"name: string .\"","Do not send a schema update whose body is empty; skip the call entirely","Validate the generated schema string is non-empty and contains ':' type lines before calling Parse"],"exampleFix":"// before\nschema := \"[0x1]\\n\"\n// after\nschema := \"[0x1]\\nname: string @index(exact) .\"","handlingStrategy":"validation","validationCode":"if !strings.Contains(strings.TrimPrefix(schemaStr, \"[0x1]\"), \":\") && strings.HasPrefix(strings.TrimSpace(schemaStr), \"[\") {\n    return fmt.Errorf(\"schema has namespace header but no predicate definitions\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := schema.Parse(s, 0, 1); err != nil {\n    if strings.Contains(err.Error(), \"No schema found after namespace\") {\n        return fmt.Errorf(\"empty schema body: %w\", err)\n    }\n    return err\n}","preventionTips":["Skip the update call entirely when the generated schema body is empty","Require at least one ':'-containing line in any templated schema","Assert schema files end with predicate/type definitions"],"tags":["dgraph","schema-parser","parsing","empty-input"],"backgroundTag":"schema-parse-empty-body","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}