{"record":{"id":"339a17a5d0e06483","repo":"dgraph-io/dgraph","slug":"facet-s-index-s-w","errorCode":null,"errorMessage":"facet: %s, index: %s: %w","messagePattern":"facet: (.+?), index: (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"chunker/json_parser.go","lineNumber":142,"sourceCode":"\t\tif facetVal == nil {\n\t\t\tcontinue\n\t\t}\n\t\tif !strings.HasPrefix(fname, prefix) {\n\t\t\tcontinue\n\t\t}\n\n\t\tfm, ok := facetVal.(map[string]interface{})\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"facets format should be of type map for \"+\n\t\t\t\t\"scalarlist predicates, found: %v for facet: %v\", facetVal, fname)\n\t\t}\n\n\t\tidxMap := make(map[int]*api.Facet, len(fm))\n\t\tfor sidx, val := range fm {\n\t\t\tkey := fname[len(prefix):]\n\t\t\tfacet, err := handleBasicFacetsType(key, val)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"facet: %s, index: %s: %w\", fname, sidx, err)\n\t\t\t}\n\t\t\tidx, err := strconv.Atoi(sidx)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"facet: %s, index: %s: %w\", fname, sidx, err)\n\t\t\t}\n\t\t\tidxMap[idx] = facet\n\t\t}\n\t\tmapSlice = append(mapSlice, idxMap)\n\t}\n\n\treturn mapSlice, nil\n}\n\n// parseScalarFacets parses facets which should be of type string/json.Number/bool.\n// It returns []*api.Facet, one *api.Facet for each facet.\nfunc parseScalarFacets(m map[string]interface{}, prefix string) ([]*api.Facet, error) {\n\t// This happens at root.\n\tif prefix == \"\" {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/chunker/json_parser.go#L124-L160","documentation":"After the string type check, HashTokenizer hashes the value with blake2b.Sum256. The code defensively checks len(hash)==0; a zero-length hash would mean hashing produced no output, which should never happen with Sum256 (fixed 32-byte output). This is a defensive, practically unreachable error.","triggerScenarios":"Theoretically when blake2b.Sum256 returns an empty slice — not reachable with the standard blake2b implementation, which always returns 32 bytes.","commonSituations":"Essentially never seen in practice; would indicate a broken/patched crypto dependency.","solutions":["No user action needed; treat as an internal invariant failure.","If it ever occurs, verify the golang.org/x/crypto/blake2b dependency integrity and rebuild.","Report it upstream with the value and environment that produced it."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"tokens, err := hashTok.Tokens(s)\nif err != nil && strings.Contains(err.Error(), \"failed to create hash\") {\n    // defensive/unreachable: verify crypto deps and rebuild\n    return nil, fmt.Errorf(\"internal hash failure: %w\", err)\n}","preventionTips":["Keep golang.org/x/crypto pinned and verify checksums.","Log the input value if this ever triggers and report upstream.","No runtime guard is needed; it is an invariant check."],"tags":["dgraph","tokenizer","hash","blake2b","defensive"],"backgroundTag":"hash-computation-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}