MarketSquare / MarketSquare/robotframework-requests

Better handling of parameters errors

Open
#319 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Python
Stars
512
Forks
283
PR merge metrics
No merged PRs in 30d

Description

Ohhhh there was a missing space before `expected_status=any` in

`Patch On Session blockfilter ${path} json=${data} headers=${headers} expected_status=any`

It would be cool to have a better error message than `AttributeError: 'str' object has no attribute 'items'`

The call stack is below if it can help to have a better message:

```
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/RequestsLibrary/utils.py", line 138, in decorator
return func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/RequestsLibrary/RequestsOnSessionKeywords.py", line 106, in patch_on_session
response = self._common_request("patch", session, url,
File "/usr/local/lib/python3.9/site-packages/RequestsLibrary/SessionKeywords.py", line 569, in _common_request
resp = method_function(
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 602, in patch
return self.request('PATCH', url, data=data, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 516, in request
prep = self.prepare_request(req)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 449, in prepare_request
p.prepare(
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 315, in prepare
self.prepare_headers(headers)
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 447, in prepare_headers
for header in headers.items():
```

_Originally posted by @dprevost-LMI in https://github.com/MarketSquare/robotframework-requests/issues/314#issuecomment-778517767_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in RequestsOnSessionKeywords.py at patch_on_session and trace the call into SessionKeywords.py::_common_request. Reproduce the malformed keyword call with the missing space before expected_status=any, then identify where the headers value reaches requests. Done means this input produces a clearer parameter error than AttributeError: 'str' object has no attribute 'items'.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.