{"record":{"id":"e44ecdbd1d885f81","repo":"weaviate/weaviate","slug":"could-not-marshal-resolve-alias-response-w","errorCode":null,"errorMessage":"could not marshal resolve alias response: %w","messagePattern":"could not marshal resolve alias response: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"warning","filePath":"cluster/schema/manager_alias.go","lineNumber":86,"sourceCode":"}\n\nfunc (s *SchemaManager) ResolveAlias(req *command.QueryRequest) ([]byte, error) {\n\tsubCommand := command.QueryResolveAliasRequest{}\n\tif err := json.Unmarshal(req.SubCommand, &subCommand); err != nil {\n\t\treturn []byte{}, fmt.Errorf(\"%w: %w\", ErrBadRequest, err)\n\t}\n\n\trootClass := s.schema.ResolveAlias(subCommand.Alias)\n\tif rootClass == \"\" {\n\t\treturn nil, fmt.Errorf(\"resolve alias: %s, %w\", subCommand.Alias, ErrAliasNotFound)\n\t}\n\n\tresponse := command.QueryResolveAliasResponse{\n\t\tClass: rootClass,\n\t}\n\tpayload, err := json.Marshal(&response)\n\tif err != nil {\n\t\treturn []byte{}, fmt.Errorf(\"could not marshal resolve alias response: %w\", err)\n\t}\n\treturn payload, nil\n}\n\nfunc (s *SchemaManager) GetAliases(req *command.QueryRequest) ([]byte, error) {\n\tsubCommand := command.QueryGetAliasesRequest{}\n\tif err := json.Unmarshal(req.SubCommand, &subCommand); err != nil {\n\t\treturn []byte{}, fmt.Errorf(\"%w: %w\", ErrBadRequest, err)\n\t}\n\n\tresponse := command.QueryGetAliasesResponse{\n\t\tAliases: s.schema.getAliases(subCommand.Alias, subCommand.Class),\n\t}\n\tpayload, err := json.Marshal(&response)\n\tif err != nil {\n\t\treturn []byte{}, fmt.Errorf(\"could not marshal get aliases response: %w\", err)\n\t}\n\treturn payload, nil","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/cluster/schema/manager_alias.go#L68-L104","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the wrapped inner error for the exact marshal failure reason.","Check whether the command.QueryResolveAliasResponse struct was recently modified with non-JSON-serializable fields and fix the type or add a Marshaler.","Retry the query — transient runtime issues rarely cause this, so persistence indicates a code/config problem."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"payload, err := mgr.ResolveAlias(req)\nif err != nil {\n  var marshalErr error\n  if strings.Contains(err.Error(), \"could not marshal resolve alias response\") {\n    marshalErr = err // response-encoding bug: report and retry once\n  }\n  return fmt.Errorf(\"resolve alias failed: %w\", err)\n}","preventionTips":["Keep command response structs limited to JSON-serializable field types.","Add unit tests that marshal every response type used by the schema manager.","If extending QueryResolveAliasResponse, implement json.Marshaler for any custom type.","Treat persistence of this error as a code defect and file a bug with the wrapped message."],"tags":["go","json","serialization","alias"],"backgroundTag":"json-marshal-failed","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}