Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST LRO fails for certain calls #1279

Closed
lqiu96 opened this issue Jan 26, 2023 · 0 comments · Fixed by #1288
Closed

REST LRO fails for certain calls #1279

lqiu96 opened this issue Jan 26, 2023 · 0 comments · Fixed by #1288
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@lqiu96
Copy link
Contributor

lqiu96 commented Jan 26, 2023

Java Sample:

package org.example;
 
import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.speech.v1.LongRunningRecognizeMetadata;
import com.google.cloud.speech.v1.LongRunningRecognizeRequest;
import com.google.cloud.speech.v1.LongRunningRecognizeResponse;
import com.google.cloud.speech.v1.RecognitionAudio;
import com.google.cloud.speech.v1.RecognitionConfig;
import com.google.cloud.speech.v1.RecognizeRequest;
import com.google.cloud.speech.v1.RecognizeResponse;
import com.google.cloud.speech.v1.SpeechClient;
import com.google.cloud.speech.v1.SpeechRecognitionResult;
import com.google.cloud.speech.v1.SpeechSettings;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.ExecutionException;
 
public class Main {
  public static void main(String[] args)
      throws IOException, ExecutionException, InterruptedException {
    String gcsUri = "gs://cloud-samples-data/speech/brooklyn_bridge.raw";
    RecognitionConfig recognitionConfig =
        RecognitionConfig.newBuilder()
            .setEncoding(RecognitionConfig.AudioEncoding.LINEAR16)
            .setSampleRateHertz(16000)
            .setLanguageCode("en-US")
            .build();
    RecognitionAudio recognitionAudio = RecognitionAudio.newBuilder().setUri(gcsUri).build();
 
    System.out.println("Running with gRPC...");
    try (SpeechClient speechClient = SpeechClient.create()) {
      testSpeechRecognize(speechClient, recognitionConfig, recognitionAudio);
    }
 
    System.out.println("Running with REST...");
    SpeechSettings speechSettings = SpeechSettings.newHttpJsonBuilder().build();
    try (SpeechClient speechClient = SpeechClient.create(speechSettings)) {
      testSpeechRecognize(speechClient, recognitionConfig, recognitionAudio);
    }
  }
 
  public static void testSpeechRecognize(
      SpeechClient speechClient,
      RecognitionConfig recognitionConfig,
      RecognitionAudio recognitionAudio)
      throws ExecutionException, InterruptedException {
    RecognizeResponse recognizeResponse =
        speechClient.recognize(
            RecognizeRequest.newBuilder()
                .setConfig(recognitionConfig)
                .setAudio(recognitionAudio)
                .build());
    List<SpeechRecognitionResult> speechRecognitionResultList = recognizeResponse.getResultsList();
    for (SpeechRecognitionResult speechRecognitionResult : speechRecognitionResultList) {
      System.out.println(
          "Transcript: " + speechRecognitionResult.getAlternatives(0).getTranscript());
    }
 
    OperationFuture<LongRunningRecognizeResponse, LongRunningRecognizeMetadata> operationFuture =
        speechClient.longRunningRecognizeAsync(
            LongRunningRecognizeRequest.newBuilder()
                .setConfig(recognitionConfig)
                .setAudio(recognitionAudio)
                .build());
    LongRunningRecognizeResponse longRunningRecognizeResponse = operationFuture.get();
    List<SpeechRecognitionResult> speechRecognitionResultOperationList =
        longRunningRecognizeResponse.getResultsList();
    for (SpeechRecognitionResult speechRecognitionResult : speechRecognitionResultOperationList) {
      System.out.println(
          "Transcript: " + speechRecognitionResult.getAlternatives(0).getTranscript());
    }
  }
}

Output:

org.example.Main
Running with gRPC...
Jan 25, 2023 3:43:35 PM com.google.auth.oauth2.DefaultCredentialsProvider warnAboutProblematicCredentials
Transcript: how old is the Brooklyn Bridge
Transcript: how old is the Brooklyn Bridge
Running with REST...
Transcript: how old is the Brooklyn Bridge
Exception in thread "main" java.util.concurrent.ExecutionException: com.google.api.gax.rpc.NotFoundException: Not Found
	at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:588)
	at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:567)
	at com.google.common.util.concurrent.FluentFuture$TrustedFuture.get(FluentFuture.java:91)
	at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:66)
	at com.google.api.gax.longrunning.OperationFutureImpl.get(OperationFutureImpl.java:125)
	at org.example.Main.testSpeechRecognize(Main.java:45)
	at org.example.Main.main(Main.java:33)
Caused by: com.google.api.gax.rpc.NotFoundException: Not Found
	at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:50)
	at com.google.api.gax.httpjson.HttpJsonApiExceptionFactory.createApiException(HttpJsonApiExceptionFactory.java:76)
	at com.google.api.gax.httpjson.HttpJsonApiExceptionFactory.create(HttpJsonApiExceptionFactory.java:54)
	at com.google.api.gax.httpjson.HttpJsonExceptionCallable$ExceptionTransformingFuture.onFailure(HttpJsonExceptionCallable.java:97)
	at com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:67)
	at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1132)
	at com.google.common.util.concurrent.DirectExecutor.execute(DirectExecutor.java:31)
	at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:1270)
	at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:1038)
	at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:808)
	at com.google.api.core.AbstractApiFuture$InternalSettableFuture.setException(AbstractApiFuture.java:94)
	at com.google.api.core.AbstractApiFuture.setException(AbstractApiFuture.java:76)
	at com.google.api.gax.httpjson.HttpJsonClientCalls$HttpJsonFuture.setException(HttpJsonClientCalls.java:112)
	at com.google.api.gax.httpjson.HttpJsonClientCalls$FutureListener.onClose(HttpJsonClientCalls.java:141)
	at com.google.api.gax.httpjson.HttpJsonClientCallImpl$OnCloseNotificationTask.call(HttpJsonClientCallImpl.java:490)
	at com.google.api.gax.httpjson.HttpJsonClientCallImpl.notifyListeners(HttpJsonClientCallImpl.java:339)
	at com.google.api.gax.httpjson.HttpJsonClientCallImpl.deliver(HttpJsonClientCallImpl.java:266)
	at com.google.api.gax.httpjson.HttpJsonClientCallImpl.setResult(HttpJsonClientCallImpl.java:149)
	at com.google.api.gax.httpjson.HttpRequestRunnable.run(HttpRequestRunnable.java:149)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: com.google.api.client.http.HttpResponseException: 404 Not Found
GET https://speech.googleapis.com:443/v1/2116618628225874900
<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=//www.google.com/><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/v1/2116618628225874900</code> was not found on this server.  <ins>That’s all we know.</ins>
 
	at com.google.api.client.http.HttpResponseException$Builder.build(HttpResponseException.java:293)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1118)
	at com.google.api.gax.httpjson.HttpRequestRunnable.run(HttpRequestRunnable.java:118)
	... 6 more
 
Process finished with exit code 1
@lqiu96 lqiu96 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 26, 2023
@lqiu96 lqiu96 self-assigned this Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant