4858: rbt post failure: CRITICAL: name 'rid' is not defined

dbalakrishnan

What version are you running?

2.0 alpha 0

What steps will reproduce the problem?

  1. Install rbt through setup.py
  2. run rbt post on a P4 changelist that already has a review board item
  3. Error occurs

What is the expected output? What do you see instead?

Expected:
Generating diff for pending changeset 2066357
Review request #263230 posted.

Current:
Generating diff for pending changeset XXXXXXX
CRITICAL: name 'rid' is not defined

What operating system are you using?

Windows/CentOS/MacOS, fails on all of 'em

Attach the debug out from the command.

>>> RBTools 2.0 alpha 0 (dev)
>>> Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)]
>>> Running on Windows-10-10.0.17763-SP0
>>> Home = C:\Users\<User>
>>> Current directory = D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3
>>> Command line: rbt post --debug 2066399
>>> Running: tf vc help
>>> Checking for a Perforce repository...
>>> Running: p4 info
>>> Running: diff --version
>>> Repository info: Path: dvp4edgepl024.tsi.lan:1666, Base path: None, Supports changesets: True
>>> Making HTTP GET request to https://reviewboard.prod.<website>.com/api/
>>> Running: p4 info
Generating diff for pending changeset 2066399
>>> Processing edit of //depot/teams/near/README.md
>>> Writing "//depot/teams/near/README.md#7" to "C:\Users\<user>~1\AppData\Local\Temp\rbtools.q29vrhge"
>>> Running: p4 print -o C:\Users\<user>~1\AppData\Local\Temp\rbtools.q29vrhge -q //depot/teams/near/README.md#7
>>> Running: diff -urNp C:\Users\<user>~1\AppData\Local\Temp\rbtools.q29vrhge d:\P4\<P4_Workspace>\README.md
>>> Command exited with rc 1: ['diff', '-urNp', 'C:\\Users\\<user>~1\\AppData\\Local\\Temp\\rbtools.q29vrhge', 'd:\\P4\\<P4_Workspace>\\README.md']
>>> Making HTTP GET request to https://reviewboard.prod.<website>.com/api/validation/diffs/
>>> Cached response for HTTP GET https://reviewboard.prod.<website>.com/api/validation/diffs/ expired and was modified
>>> Making HTTP POST request to https://reviewboard.prod.<website>.com/api/validation/diffs/
>>> Making HTTP GET request to https://reviewboard.prod.<website>.com/api/review-requests/?only-fields=&only-links=create
>>> Cached response for HTTP GET https://reviewboard.prod.<website>.com/api/review-requests/?only-fields=&only-links=create expired and was modified
>>> Making HTTP POST request to https://reviewboard.prod.<website>.com/api/review-requests/
>>> Got API Error 204 (HTTP code 409): The commit ID specified has already been used.
>>> Error data: {'stat': 'fail', 'review_request': {'status': 'pending', 'last_updated': '2020-01-23T04:25:21Z', 'target_people': [{'href': 'https://reviewboard.prod.<website>.com/api/users/<User>/', 'method': 'GET', 'title': '<User>'}], 'depends_on': [], 'description_text_type': 'plain', 'issue_resolved_count': 0, 'commit_id': '2066399', 'ship_it_count': 0, 'close_description_text_type': 'plain', 'id': 263230, 'links': {'diffs': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/diffs/', 'method': 'GET'}, 'latest_diff': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/diffs/1/', 'method': 'GET'}, 'repository': {'href': 'https://reviewboard.prod.<website>.com/api/repositories/13/', 'method': 'GET', 'title': 'Master Broker'}, 'screenshots': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/screenshots/', 'method': 'GET'}, 'self': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/', 'method': 'GET'}, 'status_updates': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/status-updates/', 'method': 'GET'}, 'update': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/', 'method': 'PUT'}, 'last_update': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/last-update/', 'method': 'GET'}, 'reviews': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/reviews/', 'method': 'GET'}, 'file_attachments': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/file-attachments/', 'method': 'GET'}, 'draft': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/draft/', 'method': 'GET'}, 'diff_context': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/diff-context/', 'method': 'GET'}, 'submitter': {'href': 'https://reviewboard.prod.<website>.com/api/users/<User>/', 'method': 'GET', 'title': '<User>'}, 'changes': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/changes/', 'method': 'GET'}, 'delete': {'href': 'https://reviewboard.prod.<website>.com/api/review-requests/263230/', 'method': 'DELETE'}}, 'issue_dropped_count': 0, 'bugs_closed': [], 'testing_done': '', 'branch': '', 'text_type': None, 'time_added': '2020-01-23T04:25:21Z', 'extra_data': {'calculated_trophies': True}, 'public': True, 'issue_verifying_count': 0, 'close_description': None, 'blocks': [], 'description': 'Test Changelist 2', 'testing_done_text_type': 'plain', 'issue_open_count': 0, 'approved': False, 'url': '/r/263230/', 'absolute_url': 'https://reviewboard.prod.<website>.com/r/263230/', 'target_groups': [], 'summary': 'Test Changelist 2', 'changenum': 2066399, 'approval_failure': 'The review request has not been marked "Ship It!"'}, 'err': {'msg': 'The commit ID specified has already been used.', 'code': 204}}
Traceback (most recent call last):
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\api\request.py", line 753, in make_request
    request.url, body, headers, request.method))
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\api\cache.py", line 209, in make_request
    return self.urlopen(request)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\urllib\request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\urllib\request.py", line 531, in open
    response = meth(req, response)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\api\request.py", line 308, in http_response
    response.info())
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\urllib\request.py", line 569, in error
    return self._call_chain(*args)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\urllib\request.py", line 503, in _call_chain
    result = func(*args)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\urllib\request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 409: CONFLICT

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\commands\post.py", line 671, in post_request
    review_request = review_requests.create(**request_data)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\api\resource.py", line 231, in <lambda>
    meth(resource, **kwargs)))
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\api\decorators.py", line 27, in request_method
    *args, **kwargs)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\api\transport\sync.py", line 77, in execute_request_method
    return self._execute_request(request)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\api\transport\sync.py", line 86, in _execute_request
    rsp = self.server.make_request(request)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\api\request.py", line 755, in make_request
    self.process_error(e.code, e.read())
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\api\request.py", line 729, in process_error
    rsp['err']['msg'])
rbtools.api.errors.APIError: The commit ID specified has already been used. (HTTP 409, API Error 204)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\Scripts\rbt-script.py", line 11, in <module>
    load_entry_point('RBTools==2.0a0', 'console_scripts', 'rbt')()
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\commands\main.py", line 120, in main
    command.run_from_argv([RB_MAIN, command_name] + args)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\commands\__init__.py", line 740, in run_from_argv
    exit_code = self.main(*args) or 0
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\commands\post.py", line 1099, in main
    submit_as=self.options.submit_as)
  File "D:\P4\<P4_Workspace>\tools\win-x86\python3.7.3\lib\site-packages\rbtools\commands\post.py", line 686, in post_request
    review_request_id=rid,
NameError: name 'rid' is not defined

Please provide any additional information below.

It seems that if rbt post is run for a P4 changelist that hasn't had a review board item published yet, it correctly submits. However, it fails when it already exists or has been discarded.

#1 dbalakrishnan

The 2.0 alpha 0 release was supposed to support Python 3.7.3 which is why we're using it. It seems this bug has been seen before (?) in previous versions of RBTools

#2 dbalakrishnan

Also, looks like the project was set to Django. This should be RBTools instead.

#3 dbalakrishnan

Is anyone available to take a look at this? This has been a major blocker for our infra upgrade to 3.7.3

#4 dbalakrishnan

Ok so we figured out the issue, and its in post.py, in the section where we post a review if it already exists. The variable "rid" has been renamed to review_request_id, but there is still one instance where you're passing in "rid".