Skip to content

fix: Expose the Baidu error if translation is not successful - #212

Merged
Green-Sky merged 1 commit into
TokTok:masterfrom
nickolay168:nickolay168/better_error_diagnostics
Sep 8, 2026
Merged

Green-Sky merged 1 commit into
TokTok:masterfrom
nickolay168:nickolay168/better_error_diagnostics

Conversation

@nickolay168

@nickolay168 nickolay168 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

If Baidu returns an error, we are getting the exception "Failed to translate 'some text' to 'some language': '' ". In this PR I have added the simple code to expose the error message. Below is the example of error, returned from Baidu.

{"errno":995,"errmsg":"request is not authorized","data":null,"logid":"1816048379","extra":"cgKinifGvSXVvMgFRVG88bkl13vdIyraxKRVaS33xbc="}

This change is Reviewable

@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Tip

Preview URL:

@github-actions github-actions Bot added the bug Bug fix for the user, not a fix to a build script label Sep 6, 2026
@nickolay168
nickolay168 force-pushed the nickolay168/better_error_diagnostics branch from 67841bd to ea9f33b Compare September 6, 2026 06:55
@nickolay168
nickolay168 marked this pull request as ready for review September 6, 2026 07:02
@Green-Sky Green-Sky added this to the v0.8.5 milestone Sep 6, 2026
@nickolay168
nickolay168 force-pushed the nickolay168/better_error_diagnostics branch from ea9f33b to 3428eb8 Compare September 8, 2026 03:32
@nickolay168
nickolay168 force-pushed the nickolay168/better_error_diagnostics branch from 3428eb8 to d3f5ad6 Compare September 8, 2026 03:54
@nickolay168
nickolay168 force-pushed the nickolay168/better_error_diagnostics branch from d3f5ad6 to 01236aa Compare September 8, 2026 03:58
@nickolay168
nickolay168 force-pushed the nickolay168/better_error_diagnostics branch from 01236aa to 531eeaf Compare September 8, 2026 04:06
@nickolay168

Copy link
Copy Markdown
Contributor Author

I have found an issue with the PR.

  1. The initial code, doing iteration used to get to the iterator end and the error was not surfaced.
  2. I have added a retries to deal with google API throttling

The question if we need to somehow supopress the error if the user is not authorized on Baidu? After the PR the translation to Lojban will always fail on the ground and on CI/CD unless we have a valid key.

@Green-Sky
Green-Sky merged commit 531eeaf into TokTok:master Sep 8, 2026
28 checks passed

This branch was successfully deployed

1 active deployment
netlify 531eeaf6 Deployed Sep 8, 2026 by Green-Sky via netlify / deploy #387
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Bug fix for the user, not a fix to a build script

Development

Successfully merging this pull request may close these issues.

2 participants