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

assignments of dict list is not supported for repeated field #135

Closed

Description

@arithmetic1728

How to reproduce:

  1. Clone https://github.com/googleapis/python-vision, switch to proto_issue branch, then install it locally.
  2. Run the following sample.
from google.cloud import vision_v1
import proto
import json

request = dict(image=vision_v1.Image(content=b"content"))
batch_req = vision_v1.BatchAnnotateImagesRequest()

# This works (converting the dict to AnnotateImageRequest first, then form a list)
# batch_req.requests = [vision_v1.AnnotateImageRequest(request)]

# This throws exception (assigning the list of dict directly)
batch_req.requests = [request]

The last line throws the following exceptions:

TypeError: Parameter to MergeFrom() must be instance of same class: expected google.cloud.vision.v1.Image got Image.

Activity

  1. added
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Sep 23, 2020
  2. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    and removed
    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.
    on Sep 24, 2020
  3. added
    🚨This issue needs some love.
    and removed
    🚨This issue needs some love.
    on Dec 23, 2020
  4. added
    priority: p3Desirable enhancement or fix. May not be included in next release.
    and removed
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Apr 12, 2021
  5. software-dov commented on Apr 12, 2021

    @software-dov
    Contributor

    The workaround is to not assign repeated fields from lists of dicts.

    The following should work:

    from google.cloud import vision_v1
    
    request = dict(image=vision_v1.Image(content=b"content"))
    batch_req = vision_v1.BatchAnnotateImagesRequest()
    batch_req.requests = [request]

    Or to use the indirect method described in the issue text above.

    Dropping priority to P3 since workarounds exist.

  6. added
    🚨This issue needs some love.
    and removed
    🚨This issue needs some love.
    on Nov 3, 2021
  7. added
    🚨This issue needs some love.
    and removed
    🚨This issue needs some love.
    on May 7, 2022
  8. parthea commented on Mar 16, 2023

    @parthea
    Contributor

    I can no longer reproduce this issue. Please open a new issue if you're still experiencing the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority: p3Desirable enhancement or fix. May not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions