Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Vision API Error isn't thrown #3

Closed

Description

@nnegrey

Was updating some samples and found when calling the Google Cloud Vision API with the python client library which has some handwritten helper methods making it a partial GAPIC library, that if the users passes a URL that the API can't reach, the API returns an error message, but the client library doesn't throw the error rather returns it as part of the response.

Call request: response = client.text_detection(image=image)
If you examine the response object from the api you'll find this:

error {
  code: 3
  message: "The URL does not appear to be accessible by us. Please double check or download the content and pass it in."
}

Seems like we should throw this error.

Related PR that I discovered this in: GoogleCloudPlatform/python-docs-samples#2569

Activity

  1. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Feb 3, 2020
  2. added
    🚨This issue needs some love.
    and removed
    🚨This issue needs some love.
    on May 3, 2020
  3. busunkim96 commented on Aug 10, 2020

    @busunkim96
    Contributor

    It doesn't look like the handwritten layer is changing the error. I get the same result when I call batch_annotate_images directly:

    from google.cloud import vision
    
    client = vision.ImageAnnotatorClient()
    
    source = vision.types.ImageSource(image_uri="https://bad-url")
    image = vision.types.Image(source=source)
    feature = vision.types.Feature(type="TEXT_DETECTION")
    
    request = vision.types.AnnotateImageRequest(image=image, features=[feature])
    response = client.batch_annotate_images(requests=[request])
    responses {
      error {
        code: 14
        message: "We can not access the URL currently. Please download the content and pass it in."
      }
    }
    

    I believe this is because the API returns a Response object with an error field instead of a gRPC error. See wrap_method, wrap_errors, and _wrap_unary_errors.

    The code that triggers a conversion from gRPC error to google.api_core.exceptions checks for a grpc.RpcError.

            except grpc.RpcError as exc:
                six.raise_from(exceptions.from_grpc_error(exc), exc)

    I think the generator is being faithful to the proto representation of the API, but it should be possible to convert the errors at the handwritten layer if desired.

  4. added
    status: investigatingThe issue is under investigation, which is determined to be non-trivial.
    and removed
    🚨This issue needs some love.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Sep 23, 2020
  5. munkhuushmgl commented on Sep 23, 2020

    @munkhuushmgl
    Contributor

    @busunkim96 Let me know how I can help to resolve this issue.

  6. added
    type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.
    and removed
    status: investigatingThe issue is under investigation, which is determined to be non-trivial.
    on Oct 22, 2021
  7. assigned and unassigned on Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: visionIssues related to the googleapis/python-vision API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions