Skip to content

[BUG]: Unable to update errors file whilst proxy is running #244

@garrytrinder

Description

@garrytrinder

Description

When making changes to the errors file whilst the proxy is running, exceptions are thrown in the proxy output and the file is not reloaded.

Expected behaviour

Proxy reloads the content of the errors file automatically.

Actual behaviour

An error is thrown on the first change but the file is reloaded.
An error is thrown on the second change but the file is not reloaded.
An error is thrown on the third change, the file is locked and cannot be overridden.

image

Environment

OS: Windows 11
Shell: PowerShell
MGDP: 0.6.0

Steps to reproduce

  1. Add a file called openai.json to the presets folder.
{
  "plugins": [
    {
      "name": "GenericRandomErrorPlugin",
      "enabled": true,
      "pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
      "configSection": "openAI",
      "urlsToWatch": [
        "https://api.openai.com/*"
      ]
    }
  ],
  "urlsToWatch": [
  ],
  "openAI": {
    "rate": 95,
    "errorsFile": "errors-openai.json"
  },
  "labelMode": "text",
  "logLevel": "info"
}
  1. Create a file called errors-openai.json in the project root.
{
  "responses": [
    {
      "statusCode": 500,
      "headers": {
        "content-type": "application/json; charset=utf-8"
      },
      "body": {
        "error": {
          "message": "The server had an error while processing your request",
          "type": "requests",
          "param": null,
          "code": null
        }
      }
    },
    {
      "statusCode": 429,
      "addDynamicRetryAfter": true,
      "headers": {
        "content-type": "application/json; charset=utf-8"
      },
      "body": {
        "error": {
          "message": "The engine is currently overloaded, please try again later.",
          "type": "requests",
          "param": null,
          "code": null
        }
      }
    },
    {
      "statusCode": 429,
      "headers": {
        "content-type": "application/json; charset=utf-8"
      },
      "body": {
        "error": {
          "message": "Rate limit reached for default-text-davinci-003 in organization org-K7hT684bLccDbBRnySOoK9f2 on tokens per min. Limit: 150000.000000 / min. Current: 160000.000000 / min. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://beta.openai.com/account/billing to add a payment method.",
          "type": "tokens",
          "param": null,
          "code": null
        }
      }
    },
    {
      "statusCode": 429,
      "headers": {
        "content-type": "application/json; charset=utf-8"
      },
      "body": {
        "error": {
          "message": "Rate limit reached for default-text-davinci-003 in organization org-K7hT684bLccDbBRnySOoK9f2 on requests per min. Limit: 60.000000 / min. Current: 70.000000 / min. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://beta.openai.com/account/billing to add a payment method.",
          "type": "requests",
          "param": null,
          "code": null
        }
      }
    }    
  ]
}
  1. Start the proxy from the project root folder using the preset configuration file.
mgdp -c /path/to/presets/openai.json
  1. Remove an object from the responses array in the errors-openai.json file. Save the file.
  2. Remove an object from the responses array in the errors-openai.json file. Save the file.
  3. Remove an object from the responses array in the errors-openai.json file. Save the file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions