{"record":{"id":"07f5f945b9e50dd0","repo":"dgraph-io/dgraph","slug":"nil-value-found","errorCode":null,"errorMessage":"nil value found","messagePattern":"nil value found","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"dgraph/cmd/migrate/table_guide.go","lineNumber":153,"sourceCode":"\t\t\t\t\t\"when getting ref label: %+v\\n\", cst)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\t\tr.refToBlank[refLabel] = blankNode\n\t}\n}\n\nfunc getCstColumns(cst *fkConstraint) map[string]interface{} {\n\tcolumnNames := make(map[string]interface{})\n\tfor _, part := range cst.parts {\n\t\tcolumnNames[part.columnName] = struct{}{}\n\t}\n\treturn columnNames\n}\n\nfunc getValue(dataType dataType, value interface{}) (string, error) {\n\tif value == nil {\n\t\treturn \"\", errors.Errorf(\"nil value found\")\n\t}\n\n\tswitch dataType {\n\tcase stringType:\n\t\treturn fmt.Sprintf(\"%s\", value), nil\n\tcase intType:\n\t\tif !value.(sql.NullInt64).Valid {\n\t\t\treturn \"\", errors.Errorf(\"found invalid nullint\")\n\t\t}\n\t\tintVal, _ := value.(sql.NullInt64).Value()\n\t\treturn fmt.Sprintf(\"%v\", intVal), nil\n\tcase datetimeType:\n\t\tif !value.(mysql.NullTime).Valid {\n\t\t\treturn \"\", errors.Errorf(\"found invalid nulltime\")\n\t\t}\n\t\tdateVal, _ := value.(mysql.NullTime).Value()\n\t\treturn fmt.Sprintf(\"%v\", dateVal), nil\n\tcase floatType:","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/dgraph/cmd/migrate/table_guide.go#L135-L171","documentation":"getValue converts a raw SQL cell into its string/RDF representation based on the column's dataType. It rejects nil cells outright with \"nil value found\" because the migrate tool has no policy for emitting NULL predicates/edges.","triggerScenarios":"dumpTable reads a row whose column value is nil (SQL NULL) for any column type (string, int, datetime, float) and calls getValue on it via outputPlainCell, generate, or createLabel.","commonSituations":"Source tables contain NULLable columns with NULL rows; joins produce missing values; columns added later without defaults left legacy rows NULL.","solutions":["Sanitize source data: replace NULLs with defaults (COALESCE) or exclude NULL rows in the SELECT.","Make columns NOT NULL with a default before migrating.","Patch table_guide.go to skip nil values instead of erroring if your use case tolerates missing predicates.","Identify the offending column from the wrapped table context and clean it."],"exampleFix":"// before\nSELECT id, nickname FROM users; -- nickname NULL -> \"nil value found\"\n// after\nSELECT id, COALESCE(nickname, '') AS nickname FROM users;","handlingStrategy":"validation","validationCode":"-- scan all columns for NULLs before migrating\nSELECT COUNT(*) FROM users WHERE col1 IS NULL OR col2 IS NULL;","typeGuard":"// Go: guard before passing to converters\nfunc isNullCell(v interface{}) bool { return v == nil }","tryCatchPattern":"if err := migrate.Run(); err != nil {\n\tif strings.Contains(err.Error(), \"nil value found\") {\n\t\tlog.Printf(\"NULL cell in source data: %+v\", err)\n\t}\n}","preventionTips":["Use COALESCE in source queries for nullable columns","Enforce NOT NULL constraints on required columns","Patch getValue to skip nils if missing predicates are acceptable"],"tags":["migration","sql","null-value"],"backgroundTag":"unexpected-null-value","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}