René's URL Explorer Experiment


Title: Obscure error message `ValueError: Request obj does not match any template` when required field is not provided · Issue #327 · googleapis/python-api-core · GitHub

Open Graph Title: Obscure error message `ValueError: Request obj does not match any template` when required field is not provided · Issue #327 · googleapis/python-api-core

X Title: Obscure error message `ValueError: Request obj does not match any template` when required field is not provided · Issue #327 · googleapis/python-api-core

Description: In PR googleapis/python-compute#147, I had to apply this change to the samples tests because a required field usage_export_location_resource was not provided. I've opened this issue because the error message ValueError: Request obj does ...

Open Graph Description: In PR googleapis/python-compute#147, I had to apply this change to the samples tests because a required field usage_export_location_resource was not provided. I've opened this issue because the err...

X Description: In PR googleapis/python-compute#147, I had to apply this change to the samples tests because a required field usage_export_location_resource was not provided. I've opened this issue because the...

Opengraph URL: https://github.com/googleapis/python-api-core/issues/327

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Obscure error message `ValueError: Request obj does not match any template` when required field is not provided","articleBody":"In PR https://github.com/googleapis/python-compute/pull/147, I had to apply [this change](https://github.com/googleapis/python-compute/pull/147/commits/e955cc63b4bf30ea84114ebb23a160a0f2b8da83) to the samples tests because a required field `usage_export_location_resource ` was not provided. I've opened this issue because the error message `ValueError: Request obj does not match any template` could be improved. We should provide more information to help users debug the issue as I found it difficult to find the root cause.\r\n\r\nSee build log [here](https://source.cloud.google.com/results/invocations/b22865c2-86f5-4ac8-bc14-feac78dcb9fd/log) and stack trace below.\r\n```\r\n=================================== FAILURES ===================================\r\n_____________________ test_set_usage_export_bucket_default _____________________\r\n\r\ncapsys = \u003c_pytest.capture.CaptureFixture object at 0x7fee8a8dd690\u003e\r\ntemp_bucket = \u003cBucket: teste4bc9ab375\u003e\r\n\r\n    def test_set_usage_export_bucket_default(capsys: typing.Any,\r\n                                             temp_bucket: storage.Bucket) -\u003e None:\r\n        set_usage_export_bucket(project_id=PROJECT, bucket_name=temp_bucket.name)\r\n        time.sleep(5)  # To make sure the settings are properly updated\r\n        uel = get_usage_export_bucket(project_id=PROJECT)\r\n        assert(uel.bucket_name == temp_bucket.name)\r\n        assert(uel.report_name_prefix == 'usage_gce')\r\n        out, _ = capsys.readouterr()\r\n        assert('default prefix of `usage_gce`.' in out)\r\n\r\n\u003e       disable_usage_export(project_id=PROJECT)\r\n\r\ntest_sample_default_values.py:48:\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\nsample_default_values.py:118: in disable_usage_export\r\n    project=project_id, usage_export_location_resource=None)\r\n../../google/cloud/compute_v1/services/projects/client.py:1399: in set_usage_export_bucket\r\n    response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)\r\n.nox/py-3-7/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py:154: in __call__\r\n    return wrapped_func(*args, **kwargs)\r\n.nox/py-3-7/lib/python3.7/site-packages/google/api_core/grpc_helpers.py:66: in error_remapped_callable\r\n    return callable_(*args, **kwargs)\r\n../../google/cloud/compute_v1/services/projects/transports/rest.py:1352: in _set_usage_export_bucket\r\n    transcoded_request = path_template.transcode(http_options, **request_kwargs)\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n\r\nhttp_options = [{'body': 'usage_export_location_resource', 'method': 'post', 'uri': '/compute/v1/projects/{project}/setUsageExportBucket'}]\r\nrequest_kwargs = {'project': 'python-docs-samples-tests-py37'}\r\nhttp_option = {'body': 'usage_export_location_resource', 'method': 'post', 'uri': '/compute/v1/projects/{project}/setUsageExportBucket'}\r\nrequest = {'uri': '/compute/v1/projects/python-docs-samples-tests-py37/setUsageExportBucket'}\r\nuri_template = '/compute/v1/projects/{project}/setUsageExportBucket'\r\npath_fields = ['project']\r\npath_args = {'project': 'python-docs-samples-tests-py37'}, leftovers = {}\r\npath_field = 'project'\r\n\r\n    def transcode(http_options, **request_kwargs):\r\n        \"\"\"Transcodes a grpc request pattern into a proper HTTP request following the rules outlined here,\r\n           https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44-L312\r\n\r\n            Args:\r\n                http_options (list(dict)): A list of dicts which consist of these keys,\r\n                    'method'    (str): The http method\r\n                    'uri'       (str): The path template\r\n                    'body'      (str): The body field name (optional)\r\n                    (This is a simplified representation of the proto option `google.api.http`)\r\n\r\n                request_kwargs (dict) : A dict representing the request object\r\n\r\n            Returns:\r\n                dict: The transcoded request with these keys,\r\n                    'method'        (str)   : The http method\r\n                    'uri'           (str)   : The expanded uri\r\n                    'body'          (dict)  : A dict representing the body (optional)\r\n                    'query_params'  (dict)  : A dict mapping query parameter variables and values\r\n\r\n            Raises:\r\n                ValueError: If the request does not match the given template.\r\n        \"\"\"\r\n        for http_option in http_options:\r\n            request = {}\r\n\r\n            # Assign path\r\n            uri_template = http_option[\"uri\"]\r\n            path_fields = [\r\n                match.group(\"name\") for match in _VARIABLE_RE.finditer(uri_template)\r\n            ]\r\n            path_args = {field: get_field(request_kwargs, field) for field in path_fields}\r\n            request[\"uri\"] = expand(uri_template, **path_args)\r\n\r\n            # Remove fields used in uri path from request\r\n            leftovers = copy.deepcopy(request_kwargs)\r\n            for path_field in path_fields:\r\n                delete_field(leftovers, path_field)\r\n\r\n            if not validate(uri_template, request[\"uri\"]) or not all(path_args.values()):\r\n                continue\r\n\r\n            # Assign body and query params\r\n            body = http_option.get(\"body\")\r\n\r\n            if body:\r\n                if body == \"*\":\r\n                    request[\"body\"] = leftovers\r\n                    request[\"query_params\"] = {}\r\n                else:\r\n                    try:\r\n                        request[\"body\"] = leftovers.pop(body)\r\n                    except KeyError:\r\n                        continue\r\n                    request[\"query_params\"] = leftovers\r\n            else:\r\n                request[\"query_params\"] = leftovers\r\n            request[\"method\"] = http_option[\"method\"]\r\n            return request\r\n\r\n\u003e       raise ValueError(\"Request obj does not match any template\")\r\nE       ValueError: Request obj does not match any template\r\n\r\n.nox/py-3-7/lib/python3.7/site-packages/google/api_core/path_template.py:300: ValueError\r\n_____________________ test_set_usage_export_bucket_custom ______________________\r\n\r\ncapsys = \u003c_pytest.capture.CaptureFixture object at 0x7fee8a74ba90\u003e\r\ntemp_bucket = \u003cBucket: teste4bc9ab375\u003e\r\n\r\n    def test_set_usage_export_bucket_custom(capsys: typing.Any,\r\n                                            temp_bucket: storage.Bucket) -\u003e None:\r\n        set_usage_export_bucket(project_id=PROJECT, bucket_name=temp_bucket.name,\r\n                                report_name_prefix=TEST_PREFIX)\r\n        time.sleep(5)  # To make sure the settings are properly updated\r\n        uel = get_usage_export_bucket(project_id=PROJECT)\r\n        assert(uel.bucket_name == temp_bucket.name)\r\n        assert(uel.report_name_prefix == TEST_PREFIX)\r\n        out, _ = capsys.readouterr()\r\n        assert('usage_gce' not in out)\r\n\r\n\u003e       disable_usage_export(project_id=PROJECT)\r\n\r\ntest_sample_default_values.py:66:\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\nsample_default_values.py:118: in disable_usage_export\r\n    project=project_id, usage_export_location_resource=None)\r\n../../google/cloud/compute_v1/services/projects/client.py:1399: in set_usage_export_bucket\r\n    response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)\r\n.nox/py-3-7/lib/python3.7/site-packages/google/api_core/gapic_v1/method.py:154: in __call__\r\n    return wrapped_func(*args, **kwargs)\r\n.nox/py-3-7/lib/python3.7/site-packages/google/api_core/grpc_helpers.py:66: in error_remapped_callable\r\n    return callable_(*args, **kwargs)\r\n../../google/cloud/compute_v1/services/projects/transports/rest.py:1352: in _set_usage_export_bucket\r\n    transcoded_request = path_template.transcode(http_options, **request_kwargs)\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n\r\nhttp_options = [{'body': 'usage_export_location_resource', 'method': 'post', 'uri': '/compute/v1/projects/{project}/setUsageExportBucket'}]\r\nrequest_kwargs = {'project': 'python-docs-samples-tests-py37'}\r\nhttp_option = {'body': 'usage_export_location_resource', 'method': 'post', 'uri': '/compute/v1/projects/{project}/setUsageExportBucket'}\r\nrequest = {'uri': '/compute/v1/projects/python-docs-samples-tests-py37/setUsageExportBucket'}\r\nuri_template = '/compute/v1/projects/{project}/setUsageExportBucket'\r\npath_fields = ['project']\r\npath_args = {'project': 'python-docs-samples-tests-py37'}, leftovers = {}\r\npath_field = 'project'\r\n\r\n    def transcode(http_options, **request_kwargs):\r\n        \"\"\"Transcodes a grpc request pattern into a proper HTTP request following the rules outlined here,\r\n           https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44-L312\r\n\r\n            Args:\r\n                http_options (list(dict)): A list of dicts which consist of these keys,\r\n                    'method'    (str): The http method\r\n                    'uri'       (str): The path template\r\n                    'body'      (str): The body field name (optional)\r\n                    (This is a simplified representation of the proto option `google.api.http`)\r\n\r\n                request_kwargs (dict) : A dict representing the request object\r\n\r\n            Returns:\r\n                dict: The transcoded request with these keys,\r\n                    'method'        (str)   : The http method\r\n                    'uri'           (str)   : The expanded uri\r\n                    'body'          (dict)  : A dict representing the body (optional)\r\n                    'query_params'  (dict)  : A dict mapping query parameter variables and values\r\n\r\n            Raises:\r\n                ValueError: If the request does not match the given template.\r\n        \"\"\"\r\n        for http_option in http_options:\r\n            request = {}\r\n\r\n            # Assign path\r\n            uri_template = http_option[\"uri\"]\r\n            path_fields = [\r\n                match.group(\"name\") for match in _VARIABLE_RE.finditer(uri_template)\r\n            ]\r\n            path_args = {field: get_field(request_kwargs, field) for field in path_fields}\r\n            request[\"uri\"] = expand(uri_template, **path_args)\r\n\r\n            # Remove fields used in uri path from request\r\n            leftovers = copy.deepcopy(request_kwargs)\r\n            for path_field in path_fields:\r\n                delete_field(leftovers, path_field)\r\n\r\n            if not validate(uri_template, request[\"uri\"]) or not all(path_args.values()):\r\n                continue\r\n\r\n            # Assign body and query params\r\n            body = http_option.get(\"body\")\r\n\r\n            if body:\r\n                if body == \"*\":\r\n                    request[\"body\"] = leftovers\r\n                    request[\"query_params\"] = {}\r\n                else:\r\n                    try:\r\n                        request[\"body\"] = leftovers.pop(body)\r\n                    except KeyError:\r\n                        continue\r\n                    request[\"query_params\"] = leftovers\r\n            else:\r\n                request[\"query_params\"] = leftovers\r\n            request[\"method\"] = http_option[\"method\"]\r\n            return request\r\n\r\n\u003e       raise ValueError(\"Request obj does not match any template\")\r\nE       ValueError: Request obj does not match any template\r\n\r\n.nox/py-3-7/lib/python3.7/site-packages/google/api_core/path_template.py:300: ValueError\r\n```\r\n\r\n","author":{"url":"https://github.com/parthea","@type":"Person","name":"parthea"},"datePublished":"2021-11-12T17:30:40.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/327/python-api-core/issues/327"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:254f6c05-bb91-364a-0413-3713a3aa2a59
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id86E2:A5482:9F3074:E84BCA:6A4E1CFE
html-safe-nonce17cfea59eb34ab48914a19330270f6cc0555ffa9c6125c8716308a175e2bd209
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NkUyOkE1NDgyOjlGMzA3NDpFODRCQ0E6NkE0RTFDRkUiLCJ2aXNpdG9yX2lkIjoiNjA1ODQ2OTIwMDA5NDk2MDg5NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacc7985e53d5c329e6688e0ae23f34454b3167ac10ecadfdd8b337f3bedd4d34df
hovercard-subject-tagissue:1093613216
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-api-core/327/issue_layout
twitter:imagehttps://opengraph.githubassets.com/d5206bbc08fc05d01bee16689867c37291024c99ca49a188a7ba83d5e2649c1f/googleapis/python-api-core/issues/327
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/d5206bbc08fc05d01bee16689867c37291024c99ca49a188a7ba83d5e2649c1f/googleapis/python-api-core/issues/327
og:image:altIn PR googleapis/python-compute#147, I had to apply this change to the samples tests because a required field usage_export_location_resource was not provided. I've opened this issue because the err...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameparthea
hostnamegithub.com
expected-hostnamegithub.com
None030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0
turbo-cache-controlno-preview
go-importgithub.com/googleapis/python-api-core git https://github.com/googleapis/python-api-core.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id226992456
octolytics-dimension-repository_nwogoogleapis/python-api-core
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id226992456
octolytics-dimension-repository_network_root_nwogoogleapis/python-api-core
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release5fe497b4815fcce3df76c0e246faa739a82c3124
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/python-api-core/issues/327#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-api-core%2Fissues%2F327
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-api-core%2Fissues%2F327
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=googleapis%2Fpython-api-core
Reloadhttps://github.com/googleapis/python-api-core/issues/327
Reloadhttps://github.com/googleapis/python-api-core/issues/327
Reloadhttps://github.com/googleapis/python-api-core/issues/327
Please reload this pagehttps://github.com/googleapis/python-api-core/issues/327
googleapis https://github.com/googleapis
python-api-corehttps://github.com/googleapis/python-api-core
Notifications https://github.com/login?return_to=%2Fgoogleapis%2Fpython-api-core
Fork 97 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-api-core
Star 144 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-api-core
Code https://github.com/googleapis/python-api-core
Issues 0 https://github.com/googleapis/python-api-core/issues
Pull requests 0 https://github.com/googleapis/python-api-core/pulls
Actions https://github.com/googleapis/python-api-core/actions
Projects https://github.com/googleapis/python-api-core/projects
Security and quality 0 https://github.com/googleapis/python-api-core/security
Insights https://github.com/googleapis/python-api-core/pulse
Code https://github.com/googleapis/python-api-core
Issues https://github.com/googleapis/python-api-core/issues
Pull requests https://github.com/googleapis/python-api-core/pulls
Actions https://github.com/googleapis/python-api-core/actions
Projects https://github.com/googleapis/python-api-core/projects
Security and quality https://github.com/googleapis/python-api-core/security
Insights https://github.com/googleapis/python-api-core/pulse
#340https://github.com/googleapis/python-api-core/pull/340
Obscure error message ValueError: Request obj does not match any template when required field is not providedhttps://github.com/googleapis/python-api-core/issues/327#top
#340https://github.com/googleapis/python-api-core/pull/340
https://github.com/atulep
priority: p2Moderately-important priority. Fix may not be included in next release.https://github.com/googleapis/python-api-core/issues?q=state%3Aopen%20label%3A%22priority%3A%20p2%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/python-api-core/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
https://github.com/parthea
partheahttps://github.com/parthea
on Nov 12, 2021https://github.com/googleapis/python-api-core/issues/327#issue-1093613216
googleapis/python-compute#147https://github.com/googleapis/python-compute/pull/147
this changehttps://github.com/googleapis/python-compute/pull/147/commits/e955cc63b4bf30ea84114ebb23a160a0f2b8da83
herehttps://source.cloud.google.com/results/invocations/b22865c2-86f5-4ac8-bc14-feac78dcb9fd/log
atulephttps://github.com/atulep
priority: p2Moderately-important priority. Fix may not be included in next release.https://github.com/googleapis/python-api-core/issues?q=state%3Aopen%20label%3A%22priority%3A%20p2%22
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.https://github.com/googleapis/python-api-core/issues?q=state%3Aopen%20label%3A%22type%3A%20bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.