Page MenuHomePhabricator

Phabricator conduit API queries are failing with 403 response
Closed, ResolvedPublic

Description

I have just returned from sabbatical and the scripts I use with phabricator are now failing with a 403 response code. Example scripts are in https://gitlab.wikimedia.org/dwisehaupt/phab_tools

Example output of the dump_column_to_csv.py script with a debug print added at line 148 to output the response:

$ ./dump_column_to_csv.py fundraising_backlog
Response:  <Response [403]> 

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/models.py", line 971, in json
    return complexjson.loads(self.text, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dwisehaupt/repos/gitlab/phab_tools/./dump_column_to_csv.py", line 330, in <module>
    main()
  File "/home/dwisehaupt/repos/gitlab/phab_tools/./dump_column_to_csv.py", line 242, in main
    project_info = query_project(api_token, args.query)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dwisehaupt/repos/gitlab/phab_tools/./dump_column_to_csv.py", line 151, in query_project
    if response.json()['result'] is None:
       ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/requests/models.py", line 975, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Is it possible that permissions to use the API calls have changed?

Event Timeline

Where are these scripts running?

The scrips are likely being blocked because they do not comply with the user-agent policy (T400119). If this is the case, response.text should point that out.

Dwisehaupt claimed this task.

@Dzahn This are running locally from my host. Not production related, just convenience scripts for our workflows.

@JJMC89 Ah interesting. That definitely lines up with when I was gone. I'll update the scripts to follow the policy.

Closing since this is for me to fix. :)

@Dwisehaupt I was asking to determine if it was from a cloud provider. We had to throttle those more. If you still have issues later please let us know if you can get more of a response text that comes with it. Cheers