diff --git a/src/content/docs/developer/modules/other/external-qa-checks.mdx b/src/content/docs/developer/modules/other/external-qa-checks.mdx index 31ea9143..7a4bc83c 100644 --- a/src/content/docs/developer/modules/other/external-qa-checks.mdx +++ b/src/content/docs/developer/modules/other/external-qa-checks.mdx @@ -105,6 +105,17 @@ An app can declare several `external-qa-check` modules. Each module becomes a se Only a synchronous check can be set to block translations. See [Synchronous Checks](#synchronous-checks).

+ + targets + +

Type: array

+

Required: no

+

Allowed values: translations, sources

+

Default: ["translations"]

+

Description: What the check runs on: translations, source strings, or both. List at least one value, each once.
+ See [Source String Checks](#source-string-checks).

+ + url @@ -127,7 +138,7 @@ An app can declare several `external-qa-check` modules. Each module becomes a se ## Communication between External QA Check App and Crowdin -Crowdin sends translations for QA validation to `runQaCheckUrl` as a `POST` request with a JSON body. The app checks the translations and answers in the same HTTP response, either [without QA issues](#expected-response-from-the-app-without-qa-issues) or [with QA issues](#expected-response-from-the-app-with-qa-issues). +Crowdin sends translations for QA validation to `runQaCheckUrl` as a `POST` request with a JSON body. The app checks the translations and answers in the same HTTP response, either [without QA issues](#expected-response-from-the-app-without-qa-issues) or [with QA issues](#expected-response-from-the-app-with-qa-issues). A module that checks source strings also gets [requests for source strings](#request-to-the-app-from-crowdin-for-source-strings). * Each request contains translations for one check, one target language, and one file (or no file in string-based projects). * The request contains the `Authorization: Bearer ` header. The token identifies the organization and the app. It doesn't identify the project or the user; these are in the request body. Verify the token with the app's client secret. Read more about [Crowdin Apps security](/developer/crowdin-apps-security/). @@ -304,7 +315,7 @@ Crowdin rejects the whole response as invalid if: * The body isn't JSON, or it isn't exactly `{"data": {"validations": [...]}}`. * Any object contains a key that isn't shown in the examples above. For example, don't add `"error": null` to a passed translation, and don't add a top-level `error` next to `data`. * `translationId` isn't an integer, or `passed` isn't a boolean. -* A translation with `"passed": false` has no `error` object. +* A translation with `"passed": false` has no `error.message`. * A translation from the request has no validation. Validations with IDs that weren't in the request are ignored. @@ -325,14 +336,106 @@ Response payload example: If the response doesn't match this example, Crowdin uses the default batch size of 500. +### Request to the App from Crowdin for Source Strings + +Request payload example: + +```json collapse={13-38} +{ + "data": { + "target": "sources", + "strings": [ + { + "id": 1234567, + "key": "update_success", + "context": "Confirmation of successful software update", + "maxLength": null, + "text": "The update was successfully installed." + } + ], + "sourceLanguage": { + "id": "en", + "name": "English", + "twoLettersCode": "en", + "threeLettersCode": "eng", + "locale": "en-US", + "pluralCategoryNames": ["one", "other"], + "pluralRules": "(n != 1)", + "pluralExamples": [1, 2], + "textDirection": "ltr", + "dialectOf": null + }, + "targetLanguages": [ + { + "id": "fr", + "name": "French", + "twoLettersCode": "fr", + "threeLettersCode": "fra", + "locale": "fr-FR", + "pluralCategoryNames": ["one", "other"], + "pluralRules": "(n > 1)", + "pluralExamples": [1, 2], + "textDirection": "ltr", + "dialectOf": null + } + ], + "project": { + "id": 123, + "type": 0, + "name": "Project Name", + "description": "Project Description", + "fields": [] + } + } +} +``` + +Notes on the request payload: + +* `target` is `sources` in every request for source strings. Requests for translations have no `target` field, so an app with both targets can tell the two request types apart by it. +* For a plural string, `text` is a JSON string with an array of its plural forms, for example, `"[\"1 file\",\"%d files\"]"`. +* The `project` object has the same fields as in [requests for translations](#request-to-the-app-from-crowdin-for-runqacheckurl), but the example shows only some of them. + +### Expected Response from the App for Source Strings + +Response payload example: + +```json +{ + "data": { + "validations": [ + { + "stringId": 1234567, + "passed": true + }, + { + "stringId": 1234568, + "passed": false, + "error": { + "message": "The text uses \"login\" as a verb. Use \"log in\".", + "details": { + "rule": "log-in-verb" + } + } + } + ] + } +} +``` + +* Return one validation for each `stringId` from the request. A string without a validation gets the **Check incomplete** QA status. +* `error.message` (optional) is the text shown next to the source string in the Editor, up to 1,000 characters. Without it, the Editor shows the check name. `error.details` and suggested fixes aren't used for source strings. +* The response must contain `data.validations`. A validation without a numeric `stringId` is ignored, and any `passed` value other than `true` counts as a failed check. +* The [time limit](#timeouts) for one request is 60 seconds. When the request fails or times out, or the response has no `data.validations`, the strings of the request get the **Check incomplete** QA status. Failed requests aren't retried: a string is checked again after its next change or a revalidation. + ## Enabling a Check in a Project When the app is installed, each `external-qa-check` module appears as a separate check in the project QA settings. A project manager enables it in **Settings > Quality assurance**. The check runs only when QA checks are enabled in the project. -For each enabled external check, a project manager chooses its severity under **Save translations**: +For each enabled external check, a project manager chooses its severity in the **Severity** column: * **Warning** (default): Translators see the QA issue and can still save the translation anyway. Asynchronous checks always use this severity. -* **Error**: A translation that fails the check isn't saved. Available only for checks with `supportsSynchronousRun: true`. When you update a project using the [Edit Project](/developer/enterprise/api/v2/#operation/api.projects.patch) API method, add the check ID to `externalQaCheckIds` and set its value in `externalQaChecksIgnorable` to `false` to make it blocking. +* **Error**: A translation that fails the check isn't saved. Available only for checks with `supportsSynchronousRun: true`. The project QA settings mark such a check **While saving**. When you update a project using the [Edit Project](/developer/enterprise/api/v2/#operation/api.projects.patch) API method, add the check ID to `externalQaCheckIds` and set its value in `externalQaChecksIgnorable` to `false` to make it blocking. If an app update removes `supportsSynchronousRun`, the check stops blocking translations in all projects and works as an asynchronous check. @@ -342,7 +445,7 @@ Changes to the module in an app update (for example, new URLs or a new `supports ### Background Checks -Every enabled external check, synchronous or not, is called in the background when: +Every enabled external check of translations, synchronous or not, is called in the background when: * A translation becomes the top translation of a string (for example, after a new translation, an approval, a vote, or when the previous top translation is deleted). * An existing translation is edited. @@ -385,7 +488,7 @@ When a translation fails a check with the **Error** severity, the app's `error.m ### Revalidation -To re-check existing translations with your app's check, call the [Revalidate QA Checks](/developer/enterprise/api/v2/#operation/api.projects.qa-checks.revalidate.post) API method and pass the check ID in `externalQaCheckIds`. You can get the ID using the [List External QA Checks](/developer/enterprise/api/v2/#operation/api.external-qa-checks.getMany) API method. The **Revalidate** button in the [project QA settings](/enterprise/project-settings/qa-checks/#revalidate-qa-checks) re-runs only **Consistent terminology** and **AI-powered check**. +To re-check existing translations with your app's check, call the [Revalidate QA Checks](/developer/enterprise/api/v2/#operation/api.projects.qa-checks.revalidate.post) API method and pass the check ID in `externalQaCheckIds`. You can get the ID using the [List External QA Checks](/developer/enterprise/api/v2/#operation/api.external-qa-checks.getMany) API method. In the [project QA settings](/enterprise/project-settings/qa-checks/#revalidate-qa-checks), the **Revalidate** dialog re-runs the checks from apps, including yours, when **External checks** is selected. Only one revalidation can run in a project at a time. Revalidation checks top translations only and doesn't retry failed requests. @@ -393,6 +496,20 @@ Only one revalidation can run in a project at a time. Revalidation checks top tr The [Validate text by QA Checks](/developer/enterprise/api/v2/#operation/api.projects.translations.validate-qa-checks.post) API method checks translations without saving them. It calls all enabled external checks, synchronous or not, with the [synchronous timeouts](#timeouts). If a check doesn't answer, the response contains the `Unable to complete check {name}.` issue. +## Source String Checks + +A module with `sources` in [`targets`](#properties) checks source strings. In the project QA settings, the check appears under [**Custom source string checks**](/enterprise/project-settings/qa-checks/#custom-source-string-checks), where a project manager enables it with the **Warning** severity. Its issues appear next to the source string in the Editor, in every target language, and never block saving. + +Crowdin Enterprise calls `runQaCheckUrl` for source strings in the background when: + +* A source string is added (for example, by a file upload), or its text, key, context, or maximum length changes. +* A project manager enables the check in a project. The check then reads every string it hasn't checked yet. +* A project manager revalidates the project with **External checks** selected. + +One request contains up to 50 source strings of one project. The batch size from `getBatchSizeUrl`, the retries, the 15-minute limit, and the [circuit breaker](#circuit-breaker) described in other sections apply to checks of translations only. + +For the request and the expected response, see [Request to the App from Crowdin for Source Strings](#request-to-the-app-from-crowdin-for-source-strings). + ## Batching Crowdin Enterprise groups the translations of one operation by target language and file, and splits each group into batches of the size the app returns from `getBatchSizeUrl`. @@ -415,8 +532,9 @@ The time limit applies to each request, not to the whole operation. | Synchronous check, several translations | 60 seconds | | Validate text by QA Checks API method | 10 seconds for one translation, 60 seconds for several translations | | Background check and revalidation | 15 minutes | +| Source string check | 60 seconds | -Failed requests aren't retried right away. Retries happen only for background checks, as described below. +Failed requests aren't retried right away. Retries happen only for background checks of translations, as described below. ## Error Handling @@ -427,12 +545,14 @@ What happens next depends on how the check was called: | Call | What happens on failure | |------|-------------------------| | Synchronous check | The translation is saved with the QA issue `Unable to complete check {name}.` (severity **Warning**). The background check calls the app again later. | -| Background check | The check is retried later, a limited number of times. If the last attempt also fails, the translations get the same issue. | -| Revalidation | The translations get the same issue right away, without retries. | +| Background check | The check is retried later, a limited number of times. If the last attempt also fails, the translations get the **Check incomplete** QA status. | +| Revalidation | The translations get the **Check incomplete** QA status right away, without retries. | | Validate text by QA Checks API method | The response contains the same issue. Nothing is saved. | The `Unable to complete check {name}.` issue never blocks a translation. It counts as a QA issue in filters and statistics, and it stays until the next successful check of that translation (for example, after the next save, a source text change, or revalidation). +The **Check incomplete** QA status isn't a QA issue and never blocks a translation either. The Editor shows which check didn't run, the **QA check incomplete** option of the **Translation QA issues** filter lists such translations, and the status clears the next time the app answers for the translation. + ### Circuit Breaker To protect an app that is down, Crowdin Enterprise stops calling it for a short time after repeated failures: @@ -459,7 +579,7 @@ Crowdin Enterprise doesn't limit how often it calls an app. The only limits are * **Everyday work**: Each save in the Editor or via the API sends a request. File uploads and auto-translations send one request per batch. * **Repeated texts**: Results aren't cached, and identical texts in different projects are checked separately. The same text is sent again when a translator saves the translation anyway, and after an approval, a vote, a source text change, a retry, or a revalidation. Auto-translation via AI with retries on QA issues sends each text twice: once for the first AI output and once for the final text. -* **Full re-checks**: When a project manager enables the check in a project, or when the Revalidate QA Checks API method is called with its ID, the top translation of every string in the project is checked, in all languages. Your app doesn't control when this happens. +* **Full re-checks**: When a project manager enables the check in a project, or when the Revalidate QA Checks API method is called with its ID, the top translation of every string in the project is checked, in all languages. Your app doesn't control when this happens. A check of source strings gets every source string of the project in the same cases, 50 strings per request. * **Parallel work**: Operations in all projects of the organization run at the same time, and each of them sends its own requests. For example, a project with 10,000 strings and 5 target languages has 50,000 top translations. Enabling the check in this project sends all of them, which is 100 requests with the default batch size. @@ -483,6 +603,7 @@ If your app depends on a service with strict rate limits, follow these recommend | Problem | Likely cause | How to fix | |---------|--------------|------------| | Translations show `Unable to complete check {name}.` | The app timed out, returned an HTTP error, or returned an invalid response. | Check that the response matches the [format rules](#response-format-rules) exactly and that the app answers within the [time limits](#timeouts). | +| Translations or source strings have the **Check incomplete** QA status | Background checks or a revalidation got no valid answer from the app (for translations, after the last attempt), or the response left a string out. | Check the [format rules](#response-format-rules) and the [time limits](#timeouts), then revalidate the check in the project. | | The check fails in all projects for about a minute | The [circuit breaker](#circuit-breaker) paused the check after repeated failures. | Fix the cause of the failures. Calls resume automatically after about a minute. | | The **Error** severity can't be selected | The module doesn't have `supportsSynchronousRun: true`. | Add `"supportsSynchronousRun": true` to the module in the manifest and update the app. | | A blocking check doesn't block some translations | The translation was added by an operation that doesn't call synchronous checks, or the app didn't answer in time. | See [Synchronous Checks](#synchronous-checks) and [Error Handling](#error-handling). |