dgraph-io/dgraph · error

facet: %s, index: %s: %w

Error message

facet: %s, index: %s: %w

What it means

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.

Source

Thrown at chunker/json_parser.go:142

		if facetVal == nil {
			continue
		}
		if !strings.HasPrefix(fname, prefix) {
			continue
		}

		fm, ok := facetVal.(map[string]interface{})
		if !ok {
			return nil, fmt.Errorf("facets format should be of type map for "+
				"scalarlist predicates, found: %v for facet: %v", facetVal, fname)
		}

		idxMap := make(map[int]*api.Facet, len(fm))
		for sidx, val := range fm {
			key := fname[len(prefix):]
			facet, err := handleBasicFacetsType(key, val)
			if err != nil {
				return nil, fmt.Errorf("facet: %s, index: %s: %w", fname, sidx, err)
			}
			idx, err := strconv.Atoi(sidx)
			if err != nil {
				return nil, fmt.Errorf("facet: %s, index: %s: %w", fname, sidx, err)
			}
			idxMap[idx] = facet
		}
		mapSlice = append(mapSlice, idxMap)
	}

	return mapSlice, nil
}

// parseScalarFacets parses facets which should be of type string/json.Number/bool.
// It returns []*api.Facet, one *api.Facet for each facet.
func parseScalarFacets(m map[string]interface{}, prefix string) ([]*api.Facet, error) {
	// This happens at root.
	if prefix == "" {

View on GitHub (pinned to 759e242be6)

Solutions

  1. No user action needed; treat as an internal invariant failure.
  2. If it ever occurs, verify the golang.org/x/crypto/blake2b dependency integrity and rebuild.
  3. Report it upstream with the value and environment that produced it.
Defensive patterns

Strategy: try-catch

Try / catch

tokens, err := hashTok.Tokens(s)
if err != nil && strings.Contains(err.Error(), "failed to create hash") {
    // defensive/unreachable: verify crypto deps and rebuild
    return nil, fmt.Errorf("internal hash failure: %w", err)
}

Prevention

When it happens

Trigger: Theoretically when blake2b.Sum256 returns an empty slice — not reachable with the standard blake2b implementation, which always returns 32 bytes.

Common situations: Essentially never seen in practice; would indicate a broken/patched crypto dependency.

Related errors


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/339a17a5d0e06483. Report an issue: GitHub.