rubberduck-ai / rubberduck-vscode

Use AI-powered code edits, explanations, code generation, error diagnosis, and chat in Visual Studio Code with the official OpenAI API.
https://marketplace.visualstudio.com/items?itemName=Rubberduck.rubberduck-vscode
MIT License
582 stars 70 forks source link

Error: Unexpected token < in JSON at position 0 #70

Open LinusKaiser opened 1 year ago

LinusKaiser commented 1 year ago

Just installed the addon to VSCode, enter the API key and started typing in a simple question like: "How can I export a pandas data frame?" for testing purposes. When I send that query I get this error message: "Error: Unexpected token < in JSON at position 0". Not sure what could have possibly went wrong, as I followed all instructions. image

lgrammel commented 1 year ago

Looks like HTML got returned at some point. Could be a firewall issue or something else. Did you see any logs in the dev console or the output?

amsyeung commented 1 year ago

The root cause is caused by the SSL certificate issue. The error message indicates that the api response is not in JSON format, may by undefined or something else.

The solution is here:

  1. Go to Preferences: Open User Settings (JSON) by press ctrl+shift+p
  2. Set http.proxyAuthorization to user:passwd@/path/to/cacert.pem in case of your certificate is password protected. If not, just enter /path/to/cacert.pem
  3. Restart the vscode and should be fine.
  4. If still got the error, please also check if http.proxyStrictSSL is false and http.proxy is set. By default, http.proxy will be inherited from the http_proxy and https_proxy environment variables.
LinusKaiser commented 1 year ago

Thank you for reaching out guys. :) This is all that my settings.json contains when I open it like you described. How do I find the path to this cacert.pem and at what palce in the json is it appropriate to enter the settings you described? An example of how it looks for you or how it should look would be helpful.

{
    "workbench.colorTheme": "Visual Studio Light",
    "jupyter.kernels.filter": [

    ],
    "json.maxItemsComputed": 25000,
    "editor.largeFileOptimizations": false,
    "workbench.colorCustomizations": {
        "terminal.foreground": "#87eee2"
    },
    "chatgpt.gpt3.apiKey": "---------------MYAPIKEY----------------",
    "notebook.output.textLineLimit": 80,
    "window.zoomLevel": -1
}