Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto translate broken. API keys not changed on save, only read once on server start #20038

Closed
eugeniumegherea opened this issue Jan 4, 2021 · 0 comments

Comments

@eugeniumegherea
Copy link

Description:

Auto translation is broken for all providers (Microsoft, google, deepl) because the API key is not changing on the server when updated from admin panel.
The key is only read once on server startup.
Current workaround: After you set the key - restart the rocketchat.

Firstly I found the issue on v3.3.3. Still is present on v3.9.4.
Based on commits, I believe it is broken from 2.0 to latest

Steps to reproduce:

  1. start a fresh rocketchat v3.9.4
  2. enable auto-translate and add deepL key
  3. as admin user (by default only admin is autotranslatable) take a livechat inquiry or start a chat with someone
  4. receive a message and watch logs -> should have a error saying API key is missing

Expected behavior:

API key should change dynamically when we change it from admin panel.

Actual behavior:

API key does not change. Even if you set the key, you MUST restart the server for it to pick up.

Server Setup Information:

Judging that last commit in that area was 1y ago, all versions 2.0.0 onwards should be affected

  • Version of Rocket.Chat Server: 3.9.4.
  • Operating System: mac big sur 11.1 + docker
  • Deployment Method: docker
  • Number of Running Instances: 1
  • MongoDB Version: 4

Client Setup Information

  • Desktop App or Browser Version: Chrome Version 87.0.4280.88
  • Operating System: mac big sur 11.1

Additional context

I believe the issue is in this line. All other providers have the same behavior:

constructor() {
super();
this.name = 'deepl-translate';
this.apiEndPointUrl = 'https://api.deepl.com/v2/translate';
// Get the service provide API key.
settings.get('AutoTranslate_DeepLAPIKey', (key, value) => {
this.apiKey = value;
});
}

Relevant logs:

server.js:204 System ➔ error Error translating message Error: failed [403] {   "error": {     "code": 403,     "message": "The request is missing a valid API key.",     "errors": [       {         "message": "The request is missing a valid API key.",         "domain": "global",         "reason": "forbidden"       }     ],     "status": "PERMISSION_DENIED"   } }
    at Object.exports.makeErrorByStatus (packages/http.js:177:10)
    at Request._callback (packages/http.js:141:24)
    at Request.self.callback (/app/bundle/programs/server/npm/node_modules/meteor/http/node_modules/request/request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.EventEmitter.emit (domain.js:483:12)
    at Request.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/http/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:315:20)
    at Request.EventEmitter.emit (domain.js:483:12)
    at IncomingMessage.<anonymous> (/app/bundle/programs/server/npm/node_modules/meteor/http/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:421:28)
    at IncomingMessage.emit (events.js:327:22)
    at IncomingMessage.EventEmitter.emit (domain.js:483:12)
    at endReadableNT (_stream_readable.js:1220:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  response: {
    statusCode: 403,
    content: '{\n' +
      '  "error": {\n' +
      '    "code": 403,\n' +
      '    "message": "The request is missing a valid API key.",\n' +
      '    "errors": [\n' +
      '      {\n' +
      '        "message": "The request is missing a valid API key.",\n' +
      '        "domain": "global",\n' +
      '        "reason": "forbidden"\n' +
      '      }\n' +
      '    ],\n' +
      '    "status": "PERMISSION_DENIED"\n' +
      '  }\n' +
      '}\n',
    headers: {
      vary: 'X-Origin, Referer, Origin,Accept-Encoding',
      'content-type': 'application/json; charset=UTF-8',
      date: 'Mon, 04 Jan 2021 11:02:32 GMT',
      server: 'ESF',
      'cache-control': 'private',
      'x-xss-protection': '0',
      'x-frame-options': 'SAMEORIGIN',
      'x-content-type-options': 'nosniff',
      'alt-svc': 'h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"',
      'accept-ranges': 'none',
      connection: 'close',
      'transfer-encoding': 'chunked'
    },
    data: { error: [Object] }
  }
}
@eugeniumegherea eugeniumegherea changed the title Auto translate keys not changed dynamically, only read once on server start Auto translate broken. API keys not changed on save, only read once on server start Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants