Program: 5672
Project: 5672
Buggy source:
/** 
 * Searches entities in the specified namespace whose metadata matches the specified query.
 * @param namespace the namespace to search in
 * @param query the query string with which to search
 * @param targets {@link MetadataSearchTargetType}s to search. If empty, all possible types will be searched
 * @param sort specifies sort field and sort order. If {@code null}, the sort order is by relevance
 * @return A set of {@link MetadataSearchResultRecord} for the given query.
 */
public MetadataSearchResponse searchMetadata(Id.Namespace namespace,String query,Set<MetadataSearchTargetType> targets,@Nullable String sort,@Nullable String cursor) throws IOException, UnauthenticatedException, UnauthorizedException, BadRequestException {
  String path=String.format("String_Node_Str",query);
  for (  MetadataSearchTargetType t : targets) {
    path+="String_Node_Str" + t;
  }
  if (sort != null) {
    path+="String_Node_Str" + URLEncoder.encode(sort,"String_Node_Str");
  }
  if (cursor != null) {
    path+="String_Node_Str" + cursor;
  }
  URL searchURL=resolve(namespace,path);
  HttpResponse response=execute(HttpRequest.get(searchURL).build(),HttpResponseStatus.BAD_REQUEST.getCode());
  if (HttpResponseStatus.BAD_REQUEST.getCode() == response.getResponseCode()) {
    throw new BadRequestException(response.getResponseBodyAsString());
  }
  return GSON.fromJson(response.getResponseBodyAsString(),MetadataSearchResponse.class);
}

Fixed version (ground truth):
/** 
 * Searches entities in the specified namespace whose metadata matches the specified query.
 * @param namespace the namespace to search in
 * @param query the query string with which to search
 * @param targets {@link MetadataSearchTargetType}s to search. If empty, all possible types will be searched
 * @param sort specifies sort field and sort order. If {@code null}, the sort order is by relevance
 * @param offset the index to start with in the search results. To return results from the beginning, pass {@code 0}
 * @param limit the number of results to return, starting from #offset. To return all, pass {@link Integer#MAX_VALUE}
 * @param numCursors the number of cursors to return in the response. A cursor identifies the first index of thenext page for pagination purposes
 * @param cursor the cursor that acts as the starting index for the requested page. This is only applicable when#sortInfo is not default. If offset is also specified, it is applied starting at the cursor. If  {@code null}, the first row is used as the cursor
 * @return A set of {@link MetadataSearchResultRecord} for the given query.
 */
public MetadataSearchResponse searchMetadata(Id.Namespace namespace,String query,Set<MetadataSearchTargetType> targets,@Nullable String sort,int offset,int limit,int numCursors,@Nullable String cursor) throws IOException, UnauthenticatedException, UnauthorizedException, BadRequestException {
  String path=String.format("String_Node_Str",query);
  for (  MetadataSearchTargetType t : targets) {
    path+="String_Node_Str" + t;
  }
  if (sort != null) {
    path+="String_Node_Str" + URLEncoder.encode(sort,"String_Node_Str");
  }
  path+="String_Node_Str" + offset;
  path+="String_Node_Str" + limit;
  path+="String_Node_Str" + numCursors;
  if (cursor != null) {
    path+="String_Node_Str" + cursor;
  }
  URL searchURL=resolve(namespace,path);
  HttpResponse response=execute(HttpRequest.get(searchURL).build(),HttpResponseStatus.BAD_REQUEST.getCode());
  if (HttpResponseStatus.BAD_REQUEST.getCode() == response.getResponseCode()) {
    throw new BadRequestException(response.getResponseBodyAsString());
  }
  return GSON.fromJson(response.getResponseBodyAsString(),MetadataSearchResponse.class);
}