Title: `from_any_pb` gives a useless error message when the type names don't match. · Issue #711 · googleapis/python-api-core · GitHub
Open Graph Title: `from_any_pb` gives a useless error message when the type names don't match. · Issue #711 · googleapis/python-api-core
X Title: `from_any_pb` gives a useless error message when the type names don't match. · Issue #711 · googleapis/python-api-core
Description: Environment details google-api-core version: pip show google-api-core = 2.19.2 Steps to reproduce Try to decode an Any with the wrong type path. The error is like: TypeError: Could not convert `Any` to `PredictLongRunningResponse` I had ...
Open Graph Description: Environment details google-api-core version: pip show google-api-core = 2.19.2 Steps to reproduce Try to decode an Any with the wrong type path. The error is like: TypeError: Could not convert `Any...
X Description: Environment details google-api-core version: pip show google-api-core = 2.19.2 Steps to reproduce Try to decode an Any with the wrong type path. The error is like: TypeError: Could not convert `Any...
Opengraph URL: https://github.com/googleapis/python-api-core/issues/711
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`from_any_pb` gives a useless error message when the type names don't match.","articleBody":"#### Environment details\r\n\r\n - `google-api-core` version: `pip show google-api-core` = 2.19.2\r\n\r\n#### Steps to reproduce\r\n\r\nTry to decode an `Any` with the wrong type path. \r\n\r\nThe error is like:\r\n\r\n```\r\nTypeError: Could not convert `Any` to `PredictLongRunningResponse` \r\n```\r\n\r\nI had to go way down in the debugger to find that the actual problem was the different versions:\r\n\r\n```\r\nTypeError: Could not convert\r\n Any[google.ai.generativelanguage.v1main.PredictLongRunningResponse] to\r\n google.ai.generativelanguage.v1beta.PredictLongRunningResponse\r\n```\r\n\r\n#### Code example\r\n\r\nIn this Colab example, the API doesn't know what version the client library is calling with and returns an `Any` with a mismatched-version.\r\n\r\nhttps://colab.research.google.com/drive/1m6KLCvp2l1oD32cnIsaBLN5ecmbFNncI?resourcekey=0-hivajkhDg2FA5Sec3pTu4w\u0026usp=sharing\r\n\r\n#### Stack trace\r\n```\r\n\u003cipython-input-112-5c7fa9bc2888\u003e(3)\u003ccell line: 3\u003e()\r\n 1 import time\r\n 2 \r\n----\u003e 3 while not op.done():\r\n 4 time.sleep(5)\r\n 5 print('waiting...')\r\n\r\n /usr/local/lib/python3.10/dist-packages/google/api_core/operation.py(174)done()\r\n 172 bool: True if the operation is complete, False otherwise.\r\n 173 \"\"\"\r\n--\u003e 174 self._refresh_and_update(retry)\r\n 175 return self._operation.done\r\n 176 \r\n\r\n /usr/local/lib/python3.10/dist-packages/google/api_core/operation.py(163)_refresh_and_update()\r\n 161 if not self._operation.done:\r\n 162 self._operation = self._refresh(retry=retry) if retry else self._refresh()\r\n--\u003e 163 self._set_result_from_operation()\r\n 164 \r\n 165 def done(self, retry=None):\r\n\r\n /usr/local/lib/python3.10/dist-packages/google/api_core/operation.py(134)_set_result_from_operation()\r\n 132 \r\n 133 if self._operation.HasField(\"response\"):\r\n--\u003e 134 response = protobuf_helpers.from_any_pb(\r\n 135 self._result_type, self._operation.response\r\n 136 )\r\n\r\n\u003e /usr/local/lib/python3.10/dist-packages/google/api_core/protobuf_helpers.py(65)from_any_pb()\r\n 63 # Unpack the Any object and populate the protobuf message instance.\r\n 64 if not any_pb.Unpack(msg_pb):\r\n---\u003e 65 raise TypeError(\r\n 66 \"Could not convert {} to {}\".format(\r\n 67 any_pb.__class__.__name__, pb_type.__name__\r\n\r\n```","author":{"url":"https://github.com/MarkDaoust","@type":"Person","name":"MarkDaoust"},"datePublished":"2024-10-01T23:51:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/711/python-api-core/issues/711"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:acf9b727-4cab-02e2-8be7-293b0b5b2f0a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B968:1FFDFF:8044F3:ADDCDA:6A4EC6E0 |
| html-safe-nonce | 99cd6c79409dc9522ddce000c7cc38781f7787cc86d533857df94fe538562d24 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTY4OjFGRkRGRjo4MDQ0RjM6QUREQ0RBOjZBNEVDNkUwIiwidmlzaXRvcl9pZCI6Ijg1MTkwMjYzMzcyODg5OTY1NzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8d1d710c28af832ac8265994285e3b0d332d144bf1f2ea62165e302a542656ed |
| hovercard-subject-tag | issue:2560398552 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-api-core/711/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e100eaa604213eafad8b9408ae41ae80985489b33bccd28e78fc25b105a95e89/googleapis/python-api-core/issues/711 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e100eaa604213eafad8b9408ae41ae80985489b33bccd28e78fc25b105a95e89/googleapis/python-api-core/issues/711 |
| og:image:alt | Environment details google-api-core version: pip show google-api-core = 2.19.2 Steps to reproduce Try to decode an Any with the wrong type path. The error is like: TypeError: Could not convert `Any... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | MarkDaoust |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b6ab3ba6d20a71766ac245b5a4a94c6fc672a9cd4da7d44c1b33ab8bf6a21c |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-api-core git https://github.com/googleapis/python-api-core.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992456 |
| octolytics-dimension-repository_nwo | googleapis/python-api-core |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992456 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-api-core |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e6a744804e8e70f97b4d5a18a94dcc63db22f97a |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width