{"record":{"id":"d27034e016e6abd8","repo":"dgraph-io/dgraph","slug":"unable-to-peek-v","errorCode":null,"errorMessage":"Unable to peek: %v","messagePattern":"Unable to peek: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"schema/parse.go","lineNumber":584,"sourceCode":"\t\tif it.Item().Typ == itemExclamationMark {\n\t\t\tit.Next()\n\t\t}\n\t}\n\n\tif it.Item().Typ != itemNewLine {\n\t\treturn nil, it.Item().Errorf(\"Expected new line after field declaration. Got %v\",\n\t\t\tit.Item().Val)\n\t}\n\n\tglog.Warningf(\"Type declaration for type %s includes deprecated information about field type \"+\n\t\t\"for field %s which will be ignored.\", typeName, x.ParseAttr(field.Predicate))\n\treturn field, nil\n}\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.","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/schema/parse.go#L566-L602","documentation":"parseNamespace in the schema lexer/parser peeks 2 tokens ahead to read a namespace like [0x1] at the start of a schema block. If the token iterator cannot peek that far (EOF or iterator exhausted), the parser wraps the underlying peek error with 'Unable to peek: %v'. It means the schema text ended before a namespace declaration could be read.","triggerScenarios":"Calling schema.Parse / ParseWithNamespace on schema DQL whose text terminates right after '[' or truncates before '<predicate>: type' following the [ns] token, e.g. an empty or cut-off schema string.","commonSituations":"Schema file truncated during upload/copy; passing an empty string; manually editing schema and deleting the body after the namespace bracket; tooling generating schema programmatically that stops emitting after the opening bracket.","solutions":["Provide the complete schema text, including '<predicate>: <type> .' entries after the [namespace] section","Check the schema source file for truncation (verify it ends with a newline/type declarations)","If namespaces are not needed, omit the '[' bracket entirely instead of emitting a dangling one","Log the raw schema string before Parse to confirm what is actually being parsed"],"exampleFix":"// before\nschema := \"name: string @index(exact) .\\n[0x1]\" // truncated after namespace\n// after\nschema := \"name: string @index(exact) .\\n[0x1]\\nname: string @index(exact) .\"","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(schemaStr) == \"\" || strings.HasSuffix(strings.TrimSpace(schemaStr), \"[\") {\n    return fmt.Errorf(\"schema text truncated before namespace\")\n}\nerr := schema.Parse(schemaStr, 0, 1)","typeGuard":null,"tryCatchPattern":"if _, err := schema.Parse(s, 0, 1); err != nil {\n    if strings.Contains(err.Error(), \"Unable to peek\") {\n        log.Fatalf(\"truncated schema: %v\\nraw=%q\", err, s)\n    }\n    return err\n}","preventionTips":["Always emit complete '<pred>: <type> .' lines after any [ns] header","Checksum/verify schema files before upload","Log the raw schema string on parse failure","Never hand-edit production schema strings without re-validating"],"tags":["dgraph","schema-parser","parsing","syntax-error"],"backgroundTag":"schema-parse-truncated-input","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}