Repository navigation
fix(tools): substitute OpenAPI path parameters whose names contain dots - #8176
Open
abhishekacharya200 wants to merge 1 commit into
Open
abhishekacharya200 wants to merge 1 commit into
abhishekacharya200 wants to merge 1 commit into
Conversation
RestApiTool filled the path template with str.format, which reads "." and
"[" in a field name as attribute and index access. A path such as
/files/{file.name} looked up "file" and raised KeyError before any request
was sent. Replace each {name} placeholder by looking up the whole name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to Issue or Description of Change
2. Or, if no issue exists, describe the change:
Problem:
RestApiToolbuilds the request path withstr.format(**path_params).str.formatreads.and[in a field name as attribute and index access, so an OpenAPI path like/files/{file.name}looks upfileand raisesKeyError: 'file'before the request is sent. Dotted names are valid in OpenAPI path templates (RFC 6570 allows.in variable names).Repro:
Solution:
Replace each
{name}placeholder by looking up the whole name in the encoded path parameters. A placeholder with no value still raisesKeyErrorwith its name, so the existing missing-parameter error is unchanged.Testing Plan
Unit Tests:
Added
test_prepare_request_params_path_param_name_with_dot_or_bracket(file.name,items[0]). It fails withKeyErrorbefore the change.Manual End-to-End (E2E) Tests:
Ran the repro above. Before:
KeyError: 'file'. After: the request URL ishttps://example.com/files/a.txt.Checklist