weaviate/weaviate · warning

could not marshal resolve alias response

Error message

could not marshal resolve alias response: %w

What it means

This wraps the json.Marshal error that occurs while serializing the QueryResolveAliasResponse (containing the resolved root class) back to the caller. It is an internal response-encoding failure, not a problem with the request.

Solutions

  1. Inspect the wrapped inner error for the exact marshal failure reason.
  2. Check whether the command.QueryResolveAliasResponse struct was recently modified with non-JSON-serializable fields and fix the type or add a Marshaler.
  3. Retry the query — transient runtime issues rarely cause this, so persistence indicates a code/config problem.
Defensive patterns

Strategy: try-catch

Try / catch

payload, err := mgr.ResolveAlias(req)
if err != nil {
  var marshalErr error
  if strings.Contains(err.Error(), "could not marshal resolve alias response") {
    marshalErr = err // response-encoding bug: report and retry once
  }
  return fmt.Errorf("resolve alias failed: %w", err)
}

Prevention

When it happens

Trigger: json.Marshal fails on the QueryResolveAliasResponse struct. In practice this is nearly impossible with a plain string field; it would require a corrupted marshaller state or a non-serializable value introduced by future field changes.

Common situations: Essentially only seen when the command package response struct is extended with custom types lacking JSON marshalling, or in exotic environments where encoding/json misbehaves.

Understand the failure class

Background: json.Marshal / "failed to marshal" errors in Go: why "unsupported type" happens and how to fix it — this error's family across 22 libraries.

Related errors


AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04). Data as JSON: /api/errors/e44ecdbd1d885f81. Report an issue: GitHub.

Appendix: source

Thrown at cluster/schema/manager_alias.go:86

}

func (s *SchemaManager) ResolveAlias(req *command.QueryRequest) ([]byte, error) {
	subCommand := command.QueryResolveAliasRequest{}
	if err := json.Unmarshal(req.SubCommand, &subCommand); err != nil {
		return []byte{}, fmt.Errorf("%w: %w", ErrBadRequest, err)
	}

	rootClass := s.schema.ResolveAlias(subCommand.Alias)
	if rootClass == "" {
		return nil, fmt.Errorf("resolve alias: %s, %w", subCommand.Alias, ErrAliasNotFound)
	}

	response := command.QueryResolveAliasResponse{
		Class: rootClass,
	}
	payload, err := json.Marshal(&response)
	if err != nil {
		return []byte{}, fmt.Errorf("could not marshal resolve alias response: %w", err)
	}
	return payload, nil
}

func (s *SchemaManager) GetAliases(req *command.QueryRequest) ([]byte, error) {
	subCommand := command.QueryGetAliasesRequest{}
	if err := json.Unmarshal(req.SubCommand, &subCommand); err != nil {
		return []byte{}, fmt.Errorf("%w: %w", ErrBadRequest, err)
	}

	response := command.QueryGetAliasesResponse{
		Aliases: s.schema.getAliases(subCommand.Alias, subCommand.Class),
	}
	payload, err := json.Marshal(&response)
	if err != nil {
		return []byte{}, fmt.Errorf("could not marshal get aliases response: %w", err)
	}
	return payload, nil

View on GitHub (pinned to 75aa4b6d11)