b24api 2.6.0__tar.gz → 2.6.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {b24api-2.6.0/b24api.egg-info → b24api-2.6.1}/PKG-INFO +40 -3
- {b24api-2.6.0 → b24api-2.6.1}/README.md +39 -2
- {b24api-2.6.0 → b24api-2.6.1}/b24api/_diagnostics.py +21 -2
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/policy.py +9 -2
- b24api-2.6.1/b24api/contracts/v3_codes.py +115 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/errors.py +14 -3
- {b24api-2.6.0 → b24api-2.6.1}/b24api/redaction.py +18 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/transport/protocol.py +3 -1
- {b24api-2.6.0 → b24api-2.6.1/b24api.egg-info}/PKG-INFO +40 -3
- b24api-2.6.0/b24api/contracts/v3_codes.py +0 -61
- {b24api-2.6.0 → b24api-2.6.1}/LICENSE +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/MANIFEST.in +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/__init__.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/_client_traversal.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/_error_types.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/_sources.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/batch/__init__.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/batch/correlation.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/batch/engine.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/batch/facade.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/batch/logical.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/batch/outcome.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/batch/stream.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/batch/v3.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/cli.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/cli_contract.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/client.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/completion/__init__.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/completion/closure.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/completion/fast_recorder.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/completion/gate.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/completion/operation_stream.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/completion/recorder.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/completion/reference_recorder.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/__init__.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/bounded_range.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/command.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/completion.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/continuation.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/dispatch.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/error_base.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/evidence.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/identity_store.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/json.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/keyset_capability.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/keyset_execution.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/page.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/page_stop.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/positional.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/reference.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/reference_source.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/report.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/request.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/request_summary.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/response.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/stream.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/traversal.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/violation.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/wire.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/contracts/wire_body.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/encoding.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/__init__.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/boundary.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/cleanup.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/context.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/executor.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/failure.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/lifecycle.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/rate.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/snapshot.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/execution/throttle.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/migration.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/py.typed +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/__init__.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/binding.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/budget_view.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/compatibility.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/counted_io.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/dispatch.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/dispatch_plan.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/facade.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/fanout.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/keyset_run.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/outcome.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/program.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/run.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/scheduler.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/sources.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/stream.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/support.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/references/wave_engine.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/settings.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/testing/__init__.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/testing/_isolation.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/testing/scripted.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/testing/transport.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/transport/__init__.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/transport/base.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/transport/decoding.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/transport/disposition.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/transport/httpx.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/transport/log_records.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/transport/logging_shield.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/__init__.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/continuation.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/control_preflight.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/counted.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/counted_batch.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/counted_io.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/counted_rules.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/cursor.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/cursor_domain.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/driver.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/facade.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/facade_support.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/identity.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/identity_ledger.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/inclusive_window.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_auto.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_capability.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_context.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_eligibility.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_fast_plan.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_fast_stream.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_geometry.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_observation.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_ordered_admission.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_page_validation.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_plan.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_reporting.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_runtime.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_step.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_transaction_contract.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_transactions.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/keyset_verifier.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/offset_rules.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/page_adaptation.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/plans.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/sequential.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/sparse.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/strategy_context.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/stream.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api/traversal/values.py +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api.egg-info/SOURCES.txt +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api.egg-info/dependency_links.txt +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api.egg-info/entry_points.txt +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api.egg-info/requires.txt +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/b24api.egg-info/top_level.txt +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/pyproject.toml +0 -0
- {b24api-2.6.0 → b24api-2.6.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: b24api
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.1
|
|
4
4
|
Summary: Bitrix24 API
|
|
5
5
|
Author-email: Shkarupa Alex <shkarupa.alex@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -127,8 +127,9 @@ may already have reached Bitrix:
|
|
|
127
127
|
|
|
128
128
|
A failure that proves the request did not run is retried whatever its safety: a transport failure
|
|
129
129
|
before dispatch, or a refusal listed in `AmbiguityPolicy`, which by default is an unstructured 423, 425
|
|
130
|
-
or 429 (`refusal_http_statuses`) or a `QUERY_LIMIT_EXCEEDED` / `OPERATION_TIME_LIMIT`
|
|
131
|
-
(`refusal_api_codes`). A code or
|
|
130
|
+
or 429 (`refusal_http_statuses`) or a `QUERY_LIMIT_EXCEEDED` / `OPERATION_TIME_LIMIT` /
|
|
131
|
+
REST 3.0 `BITRIX_REST_V3_EXCEPTION_RATELIMITEXCEPTION` refusal (`refusal_api_codes`). A code or
|
|
132
|
+
status added only to `RetryPolicy` is retried for `SAFE` work alone.
|
|
132
133
|
A physical batch applies these rules to each command: after a failure, only the commands that
|
|
133
134
|
may run again are sent again, in a smaller batch, and an `UNSAFE` command of a batch that may have run
|
|
134
135
|
arrives as unknown. Replay rounds spend the same attempt and retry-time budget as the sends before
|
|
@@ -161,6 +162,42 @@ one_attempt = dataclasses.replace(ExecutionPolicy.from_settings(settings), max_a
|
|
|
161
162
|
result = await client.call(request, policy=one_attempt)
|
|
162
163
|
```
|
|
163
164
|
|
|
165
|
+
### Error codes
|
|
166
|
+
|
|
167
|
+
A structured refusal raises `ApiResponseError`. Its message, `wire_code`, `normalized_code`, `code`
|
|
168
|
+
(lower case) and `to_safe_dict()` name the server's code, so failures can be told apart:
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
API error [BITRIX_REST_V3_EXCEPTION_ACCESSDENIEDEXCEPTION]: Access denied
|
|
172
|
+
API error [NOTE_EMPTY_UPDATE]: Nothing to update
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
A REST 3.0 `error.code` is shown verbatim whenever it is a snake-case identifier: upper case, such
|
|
176
|
+
as `BITRIX_REST_V3_EXCEPTION_INVALIDSELECTEXCEPTION` or `FEATURE_NOT_AVAILABLE_ON_CURRENT_PLAN`, or
|
|
177
|
+
lower case of letters only, such as `invalid_select_field`; the server's set is open, so no list is
|
|
178
|
+
kept. Error texts, classic
|
|
179
|
+
`{"error": ...}` codes and response previews keep the conservative redaction, so a long run of
|
|
180
|
+
letters and digits there still renders as `[REDACTED]`. A code that equals or contains your
|
|
181
|
+
webhook token or a credential of the request, in any letter case, is always `[REDACTED]`; one that
|
|
182
|
+
names a field of your request is shown as its `field#N` alias, or as `[REDACTED]` when only its
|
|
183
|
+
letter case differs.
|
|
184
|
+
|
|
185
|
+
Recognizing a code does not make it retryable. By default only the REST 3.0 load limits are retried,
|
|
186
|
+
after the server's `Retry-After`:
|
|
187
|
+
|
|
188
|
+
| Code | Status | Retried |
|
|
189
|
+
|---|---|---|
|
|
190
|
+
| `BITRIX_REST_V3_EXCEPTION_RATELIMITEXCEPTION` | 429 | Any direct request: the limiter refuses before the method runs. In a REST 3.0 batch envelope only `SAFE` commands, as for any structured envelope error. |
|
|
191
|
+
| `BITRIX_REST_V3_EXCEPTION_LIMITER_QUERYTIMELIMITEXCEPTION` | 503 | `SAFE` requests only: the method may have run. |
|
|
192
|
+
|
|
193
|
+
Every other REST 3.0 code is a deterministic refusal and is raised at once, including a 429 or 503
|
|
194
|
+
that a module declares for a longer-lived state (`LANDING_AI_SITE_MODERATION_BLOCK_LIMIT`,
|
|
195
|
+
`LANDING_AI_MODULE_UNAVAILABLE`). List more codes in `RetryPolicy.transient_api_codes` (and in
|
|
196
|
+
`AmbiguityPolicy.refusal_api_codes` when the code proves the method did not run). The request
|
|
197
|
+
faults `BITRIX_REST_V3_EXCEPTION_VALIDATION_REQUESTVALIDATIONEXCEPTION` and
|
|
198
|
+
`BITRIX_REST_V3_EXCEPTION_METHODNOTFOUNDEXCEPTION` in a REST 3.0 error envelope are never retried,
|
|
199
|
+
even when listed.
|
|
200
|
+
|
|
164
201
|
## Logical batch and correlation
|
|
165
202
|
|
|
166
203
|
`batch()` accepts an arbitrary-length synchronous or asynchronous command source. It consumes the
|
|
@@ -96,8 +96,9 @@ may already have reached Bitrix:
|
|
|
96
96
|
|
|
97
97
|
A failure that proves the request did not run is retried whatever its safety: a transport failure
|
|
98
98
|
before dispatch, or a refusal listed in `AmbiguityPolicy`, which by default is an unstructured 423, 425
|
|
99
|
-
or 429 (`refusal_http_statuses`) or a `QUERY_LIMIT_EXCEEDED` / `OPERATION_TIME_LIMIT`
|
|
100
|
-
(`refusal_api_codes`). A code or
|
|
99
|
+
or 429 (`refusal_http_statuses`) or a `QUERY_LIMIT_EXCEEDED` / `OPERATION_TIME_LIMIT` /
|
|
100
|
+
REST 3.0 `BITRIX_REST_V3_EXCEPTION_RATELIMITEXCEPTION` refusal (`refusal_api_codes`). A code or
|
|
101
|
+
status added only to `RetryPolicy` is retried for `SAFE` work alone.
|
|
101
102
|
A physical batch applies these rules to each command: after a failure, only the commands that
|
|
102
103
|
may run again are sent again, in a smaller batch, and an `UNSAFE` command of a batch that may have run
|
|
103
104
|
arrives as unknown. Replay rounds spend the same attempt and retry-time budget as the sends before
|
|
@@ -130,6 +131,42 @@ one_attempt = dataclasses.replace(ExecutionPolicy.from_settings(settings), max_a
|
|
|
130
131
|
result = await client.call(request, policy=one_attempt)
|
|
131
132
|
```
|
|
132
133
|
|
|
134
|
+
### Error codes
|
|
135
|
+
|
|
136
|
+
A structured refusal raises `ApiResponseError`. Its message, `wire_code`, `normalized_code`, `code`
|
|
137
|
+
(lower case) and `to_safe_dict()` name the server's code, so failures can be told apart:
|
|
138
|
+
|
|
139
|
+
```text
|
|
140
|
+
API error [BITRIX_REST_V3_EXCEPTION_ACCESSDENIEDEXCEPTION]: Access denied
|
|
141
|
+
API error [NOTE_EMPTY_UPDATE]: Nothing to update
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
A REST 3.0 `error.code` is shown verbatim whenever it is a snake-case identifier: upper case, such
|
|
145
|
+
as `BITRIX_REST_V3_EXCEPTION_INVALIDSELECTEXCEPTION` or `FEATURE_NOT_AVAILABLE_ON_CURRENT_PLAN`, or
|
|
146
|
+
lower case of letters only, such as `invalid_select_field`; the server's set is open, so no list is
|
|
147
|
+
kept. Error texts, classic
|
|
148
|
+
`{"error": ...}` codes and response previews keep the conservative redaction, so a long run of
|
|
149
|
+
letters and digits there still renders as `[REDACTED]`. A code that equals or contains your
|
|
150
|
+
webhook token or a credential of the request, in any letter case, is always `[REDACTED]`; one that
|
|
151
|
+
names a field of your request is shown as its `field#N` alias, or as `[REDACTED]` when only its
|
|
152
|
+
letter case differs.
|
|
153
|
+
|
|
154
|
+
Recognizing a code does not make it retryable. By default only the REST 3.0 load limits are retried,
|
|
155
|
+
after the server's `Retry-After`:
|
|
156
|
+
|
|
157
|
+
| Code | Status | Retried |
|
|
158
|
+
|---|---|---|
|
|
159
|
+
| `BITRIX_REST_V3_EXCEPTION_RATELIMITEXCEPTION` | 429 | Any direct request: the limiter refuses before the method runs. In a REST 3.0 batch envelope only `SAFE` commands, as for any structured envelope error. |
|
|
160
|
+
| `BITRIX_REST_V3_EXCEPTION_LIMITER_QUERYTIMELIMITEXCEPTION` | 503 | `SAFE` requests only: the method may have run. |
|
|
161
|
+
|
|
162
|
+
Every other REST 3.0 code is a deterministic refusal and is raised at once, including a 429 or 503
|
|
163
|
+
that a module declares for a longer-lived state (`LANDING_AI_SITE_MODERATION_BLOCK_LIMIT`,
|
|
164
|
+
`LANDING_AI_MODULE_UNAVAILABLE`). List more codes in `RetryPolicy.transient_api_codes` (and in
|
|
165
|
+
`AmbiguityPolicy.refusal_api_codes` when the code proves the method did not run). The request
|
|
166
|
+
faults `BITRIX_REST_V3_EXCEPTION_VALIDATION_REQUESTVALIDATIONEXCEPTION` and
|
|
167
|
+
`BITRIX_REST_V3_EXCEPTION_METHODNOTFOUNDEXCEPTION` in a REST 3.0 error envelope are never retried,
|
|
168
|
+
even when listed.
|
|
169
|
+
|
|
133
170
|
## Logical batch and correlation
|
|
134
171
|
|
|
135
172
|
`batch()` accepts an arbitrary-length synchronous or asynchronous command source. It consumes the
|
|
@@ -14,7 +14,7 @@ import re
|
|
|
14
14
|
from collections.abc import Iterable, Mapping, Sequence
|
|
15
15
|
from typing import NoReturn
|
|
16
16
|
|
|
17
|
-
from b24api.redaction import DEFAULT_SENSITIVE_KEYS, is_secret, replace_secrets, secret_values
|
|
17
|
+
from b24api.redaction import DEFAULT_SENSITIVE_KEYS, contains_secret, is_secret, replace_secrets, secret_values
|
|
18
18
|
|
|
19
19
|
_ALIASED_PARAMETERS = frozenset({"filter", "order", "fields", "select"})
|
|
20
20
|
_SENSITIVE_NAMES = frozenset(name.casefold().replace("-", "_") for name in DEFAULT_SENSITIVE_KEYS)
|
|
@@ -29,7 +29,7 @@ _MAX_SECRET_DEPTH = 32
|
|
|
29
29
|
class DiagnosticContext:
|
|
30
30
|
"""Aliases and exact secrets of one canonical request, resolved on first use."""
|
|
31
31
|
|
|
32
|
-
__slots__ = ("_aliases", "_headers", "_parameters", "_pattern", "_secrets")
|
|
32
|
+
__slots__ = ("_aliases", "_folded_pattern", "_headers", "_parameters", "_pattern", "_secrets")
|
|
33
33
|
|
|
34
34
|
def __init__(
|
|
35
35
|
self,
|
|
@@ -42,6 +42,7 @@ class DiagnosticContext:
|
|
|
42
42
|
self._headers = tuple(headers)
|
|
43
43
|
self._aliases: dict[str, str] | None = None
|
|
44
44
|
self._pattern: re.Pattern[str] | None = None
|
|
45
|
+
self._folded_pattern: re.Pattern[str] | None = None
|
|
45
46
|
self._secrets: frozenset[str] = frozenset()
|
|
46
47
|
|
|
47
48
|
def __repr__(self) -> str:
|
|
@@ -65,6 +66,24 @@ class DiagnosticContext:
|
|
|
65
66
|
self._resolved()
|
|
66
67
|
return is_secret(value, self._secrets, ignore_case=ignore_case)
|
|
67
68
|
|
|
69
|
+
def contains_known_secret(self, text: str) -> bool:
|
|
70
|
+
"""Report whether any of the request's own exact secrets occurs in ``text``, ignoring letter case."""
|
|
71
|
+
self._resolved()
|
|
72
|
+
return contains_secret(text, self._secrets)
|
|
73
|
+
|
|
74
|
+
def aliases_text(self, text: str) -> bool:
|
|
75
|
+
"""Report whether ``text`` holds a whole declared field name, ignoring letter case.
|
|
76
|
+
|
|
77
|
+
Rendering aliases only the exact spelling; Bitrix field names are case-insensitive, so this check
|
|
78
|
+
also reports a field name the server echoed in another letter case.
|
|
79
|
+
"""
|
|
80
|
+
self._resolved()
|
|
81
|
+
if self._pattern is None:
|
|
82
|
+
return False
|
|
83
|
+
if self._folded_pattern is None:
|
|
84
|
+
self._folded_pattern = re.compile(self._pattern.pattern, re.IGNORECASE)
|
|
85
|
+
return self._folded_pattern.search(text) is not None
|
|
86
|
+
|
|
68
87
|
def replace_secrets(self, text: str) -> str:
|
|
69
88
|
"""Replace the request's own exact secrets wherever they occur."""
|
|
70
89
|
self._resolved()
|
|
@@ -9,6 +9,7 @@ from typing import TYPE_CHECKING
|
|
|
9
9
|
|
|
10
10
|
from b24api.contracts.error_base import BudgetExceededError
|
|
11
11
|
from b24api.contracts.json import _is_plain_int
|
|
12
|
+
from b24api.contracts.v3_codes import REFUSAL_V3_ERROR_CODES, TRANSIENT_V3_ERROR_CODES
|
|
12
13
|
|
|
13
14
|
if TYPE_CHECKING:
|
|
14
15
|
from b24api.contracts.request_summary import RequestSummary
|
|
@@ -129,7 +130,10 @@ class AmbiguityPolicy:
|
|
|
129
130
|
|
|
130
131
|
ambiguous_unstructured_statuses: frozenset[int] = frozenset({408, *range(500, 600)})
|
|
131
132
|
refusal_http_statuses: frozenset[int] = frozenset({423, 425, 429})
|
|
132
|
-
|
|
133
|
+
# The classic request and time quotas, and the REST 3.0 load limiter's refusal.
|
|
134
|
+
refusal_api_codes: frozenset[str] = frozenset(
|
|
135
|
+
{"query_limit_exceeded", "operation_time_limit", *REFUSAL_V3_ERROR_CODES}
|
|
136
|
+
)
|
|
133
137
|
|
|
134
138
|
def __post_init__(self) -> None:
|
|
135
139
|
"""Validate and freeze the status and code sets."""
|
|
@@ -188,7 +192,10 @@ class RetryPolicy:
|
|
|
188
192
|
"""Explicit retry classifications and delay bounds."""
|
|
189
193
|
|
|
190
194
|
transient_http_statuses: frozenset[int] = frozenset({423, 425, 429, 500, 502, 503, 507})
|
|
191
|
-
|
|
195
|
+
# The classic request and time quotas, and the REST 3.0 load limits; codes compare without letter case.
|
|
196
|
+
transient_api_codes: frozenset[str] = frozenset(
|
|
197
|
+
{"query_limit_exceeded", "operation_time_limit", *TRANSIENT_V3_ERROR_CODES}
|
|
198
|
+
)
|
|
192
199
|
initial_delay: float = 0.5
|
|
193
200
|
maximum_delay: float = 30.0
|
|
194
201
|
backoff: float = 2.0
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"""REST 3.0 error codes: how a structured code is recognized, and the few codes b24api acts on.
|
|
2
|
+
|
|
3
|
+
Recognition and retry are separate decisions.
|
|
4
|
+
|
|
5
|
+
Recognition decides only whether a code may be shown verbatim. A REST 3.0 server names its refusal in
|
|
6
|
+
``error.code``, and that set is open: by default the code is the upper-cased PHP class name of the
|
|
7
|
+
thrown exception (``BITRIX_REST_V3_EXCEPTION_ACCESSDENIEDEXCEPTION``), but any module may subclass the
|
|
8
|
+
server exception and override the code (``NOTE_EMPTY_UPDATE``, ``FEATURE_NOT_AVAILABLE_ON_CURRENT_PLAN``,
|
|
9
|
+
lower-case ``invalid_select_field``). A closed list would drift, so the structured ``error.code`` of a
|
|
10
|
+
REST 3.0 envelope is recognized by shape: an ASCII snake-case identifier of at least two words, upper
|
|
11
|
+
case with each word starting with a letter, or lower case of letters only. That shape is applied to
|
|
12
|
+
nothing else: free text, a classic ``{"error": ...}`` code and every other channel keep the conservative
|
|
13
|
+
bare-credential redaction, which hides any 16+ character run of letters and digits. Recognition never
|
|
14
|
+
overrides a registered exact secret, the request's own secrets or its field names: a code holding a
|
|
15
|
+
secret in any letter case is redacted whole, and one holding a request field name is aliased, or
|
|
16
|
+
redacted when only its letter case differs from the request's spelling.
|
|
17
|
+
|
|
18
|
+
Retry is decided by the policy, not by recognition. ``RetryPolicy.transient_api_codes`` and
|
|
19
|
+
``AmbiguityPolicy.refusal_api_codes`` include the server's load limiter codes by default; every other
|
|
20
|
+
code, recognized or not, is a deterministic refusal unless the caller lists it. A REST 3.0 envelope
|
|
21
|
+
with one of the two codes in ``NON_RETRYABLE_V3_ERROR_CODES`` is never retried, even when listed.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from __future__ import annotations
|
|
25
|
+
import re
|
|
26
|
+
from typing import TYPE_CHECKING
|
|
27
|
+
|
|
28
|
+
from b24api.redaction import DEFAULT_REDACTOR, REDACTED, Redactor
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from b24api._diagnostics import DiagnosticContext
|
|
32
|
+
|
|
33
|
+
VALIDATION_ERROR_CODE = "BITRIX_REST_V3_EXCEPTION_VALIDATION_REQUESTVALIDATIONEXCEPTION"
|
|
34
|
+
METHOD_NOT_FOUND_ERROR_CODE = "BITRIX_REST_V3_EXCEPTION_METHODNOTFOUNDEXCEPTION"
|
|
35
|
+
# 429, thrown by the load limiter's check before the method starts: a refusal that proves nothing ran.
|
|
36
|
+
RATE_LIMIT_ERROR_CODE = "BITRIX_REST_V3_EXCEPTION_RATELIMITEXCEPTION"
|
|
37
|
+
# 503, thrown when the database killed a query of the running method on its time limit: it may have run.
|
|
38
|
+
QUERY_TIME_LIMIT_ERROR_CODE = "BITRIX_REST_V3_EXCEPTION_LIMITER_QUERYTIMELIMITEXCEPTION"
|
|
39
|
+
|
|
40
|
+
# Deterministic request faults: never retried, even when a caller lists them as transient.
|
|
41
|
+
NON_RETRYABLE_V3_ERROR_CODES = frozenset({VALIDATION_ERROR_CODE, METHOD_NOT_FOUND_ERROR_CODE})
|
|
42
|
+
# Load limits worth another attempt after the server's ``Retry-After``; the retry policy lists them by default.
|
|
43
|
+
TRANSIENT_V3_ERROR_CODES = frozenset({RATE_LIMIT_ERROR_CODE, QUERY_TIME_LIMIT_ERROR_CODE})
|
|
44
|
+
# The subset that proves the request did not run; the ambiguity policy lists it by default.
|
|
45
|
+
REFUSAL_V3_ERROR_CODES = frozenset({RATE_LIMIT_ERROR_CODE})
|
|
46
|
+
# The codes b24api names itself. They render verbatim in every channel; any other code only by shape.
|
|
47
|
+
KNOWN_V3_ERROR_CODES = NON_RETRYABLE_V3_ERROR_CODES | TRANSIENT_V3_ERROR_CODES
|
|
48
|
+
_KNOWN_FOLDED = frozenset(code.casefold() for code in KNOWN_V3_ERROR_CODES)
|
|
49
|
+
# Upper-case codes carry digits only in version words (``V2``, ``V3``, ``B2E``); every lower-case code the
|
|
50
|
+
# server sends is letters only, which keeps lower-case credentials such as ``sk_live_a1b2c3...`` out.
|
|
51
|
+
_UPPER_CODE_SHAPE = re.compile(r"[A-Z][A-Z0-9]*(?:_[A-Z][A-Z0-9]*)+")
|
|
52
|
+
_LOWER_CODE_SHAPE = re.compile(r"[a-z]+(?:_[a-z]+)+")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def is_known_v3_code(code: str) -> bool:
|
|
56
|
+
"""Report whether a wire code is one of the fixed known V3 literals, ignoring case only."""
|
|
57
|
+
return code.casefold() in _KNOWN_FOLDED
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def is_v3_code_shape(code: str) -> bool:
|
|
61
|
+
"""Report whether a string has the shape of a REST 3.0 ``error.code``, in upper or lower case.
|
|
62
|
+
|
|
63
|
+
The shape is ASCII snake case of at least two words: upper case with each word starting with a
|
|
64
|
+
letter (``BITRIX_REST_V3_EXCEPTION_RATELIMITEXCEPTION``, ``NOTE_EMPTY_UPDATE``), or lower case of
|
|
65
|
+
letters only (``invalid_select_field``). Mixed case, a word starting with a digit
|
|
66
|
+
(``UF_CRM_1700000000123``), a lower-case digit or any other character is not.
|
|
67
|
+
"""
|
|
68
|
+
return _UPPER_CODE_SHAPE.fullmatch(code) is not None or _LOWER_CODE_SHAPE.fullmatch(code) is not None
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def render_code(
|
|
72
|
+
code: str | int,
|
|
73
|
+
*,
|
|
74
|
+
redactor: Redactor = DEFAULT_REDACTOR,
|
|
75
|
+
context: DiagnosticContext | None = None,
|
|
76
|
+
v3_envelope: bool = False,
|
|
77
|
+
) -> str:
|
|
78
|
+
"""Render one structured error code: exact secret, then known literal, then V3 shape, then free text.
|
|
79
|
+
|
|
80
|
+
Recognition never overrides an exact secret: a code that equals or contains a registered or request
|
|
81
|
+
secret, in any letter case, is redacted whole. A known literal is recognized up to letter case, so the
|
|
82
|
+
lower-cased public ``code`` attribute stays diagnosable. With ``v3_envelope``, the code came from
|
|
83
|
+
``error.code`` of a REST 3.0 envelope, and a code of the V3 shape is shown unless it holds a request
|
|
84
|
+
field name in any letter case, which is aliased, or redacted when only its case differs. Anything
|
|
85
|
+
else is free text.
|
|
86
|
+
"""
|
|
87
|
+
text = str(code)
|
|
88
|
+
# Free-text replacement is case-sensitive, and a code is also shown lower-cased: a code that holds a
|
|
89
|
+
# secret in any letter case is hidden whole.
|
|
90
|
+
if redactor.contains_known_secret(text) or (context is not None and context.contains_known_secret(text)):
|
|
91
|
+
return REDACTED
|
|
92
|
+
if is_known_v3_code(text):
|
|
93
|
+
return text
|
|
94
|
+
if v3_envelope and is_v3_code_shape(text):
|
|
95
|
+
if context is None or not context.aliases_text(text):
|
|
96
|
+
return text
|
|
97
|
+
# A request field name, possibly in another letter case than the request spelled it, is never shown.
|
|
98
|
+
rendered = redactor.render_text(text, context=context)
|
|
99
|
+
return rendered if rendered != text else REDACTED
|
|
100
|
+
return redactor.render_text(text, context=context)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
__all__ = [
|
|
104
|
+
"KNOWN_V3_ERROR_CODES",
|
|
105
|
+
"METHOD_NOT_FOUND_ERROR_CODE",
|
|
106
|
+
"NON_RETRYABLE_V3_ERROR_CODES",
|
|
107
|
+
"QUERY_TIME_LIMIT_ERROR_CODE",
|
|
108
|
+
"RATE_LIMIT_ERROR_CODE",
|
|
109
|
+
"REFUSAL_V3_ERROR_CODES",
|
|
110
|
+
"TRANSIENT_V3_ERROR_CODES",
|
|
111
|
+
"VALIDATION_ERROR_CODE",
|
|
112
|
+
"is_known_v3_code",
|
|
113
|
+
"is_v3_code_shape",
|
|
114
|
+
"render_code",
|
|
115
|
+
]
|
|
@@ -113,11 +113,22 @@ class ApiResponseError(B24ApiError):
|
|
|
113
113
|
self.original_code = code
|
|
114
114
|
self.code = str(code).lower()
|
|
115
115
|
self.normalized_code = str(code) if code_is_exact else str(code).strip().casefold()
|
|
116
|
-
|
|
116
|
+
# Only a REST 3.0 envelope's ``error.code`` may be recognized by its shape, and only as it came on the
|
|
117
|
+
# wire. Its derived forms follow that one decision: a shown code is shown lower-cased too (the secret
|
|
118
|
+
# and field checks ignore case), and a hidden or aliased one is rendered exactly as the wire code was,
|
|
119
|
+
# since a second, case-sensitive pass over another spelling could miss what the first one hid.
|
|
120
|
+
self.wire_code = render_code(code, redactor=redactor, context=diagnostics, v3_envelope=code_is_exact)
|
|
121
|
+
if code_is_exact:
|
|
122
|
+
shown = self.wire_code == str(code)
|
|
123
|
+
safe_code = self.code if shown else self.wire_code
|
|
124
|
+
safe_normalized = self.normalized_code if shown else self.wire_code
|
|
125
|
+
else:
|
|
126
|
+
safe_code = render_code(self.code, redactor=redactor, context=diagnostics)
|
|
127
|
+
safe_normalized = render_code(self.normalized_code, redactor=redactor, context=diagnostics)
|
|
117
128
|
self._safe_codes = {
|
|
118
129
|
"original_code": code if isinstance(code, int) else self.wire_code,
|
|
119
|
-
"code":
|
|
120
|
-
"normalized_code":
|
|
130
|
+
"code": safe_code,
|
|
131
|
+
"normalized_code": safe_normalized,
|
|
121
132
|
}
|
|
122
133
|
self.validation = tuple(validation)
|
|
123
134
|
self.truncated = truncated
|
|
@@ -122,6 +122,20 @@ def replace_secrets(text: str, secrets: frozenset[str]) -> str:
|
|
|
122
122
|
return text
|
|
123
123
|
|
|
124
124
|
|
|
125
|
+
def contains_secret(text: str, secrets: frozenset[str]) -> bool:
|
|
126
|
+
"""Report whether ``replace_secrets`` would hide any part of ``text`` once letter case is ignored."""
|
|
127
|
+
folded = text.casefold()
|
|
128
|
+
for secret in secrets:
|
|
129
|
+
needle = secret.casefold()
|
|
130
|
+
if needle not in folded:
|
|
131
|
+
continue
|
|
132
|
+
if len(secret) >= MINIMUM_SECRET_LENGTH:
|
|
133
|
+
return True
|
|
134
|
+
if re.search(rf"(?<![{_WORD_RUN}]){re.escape(needle)}(?![{_WORD_RUN}])", folded):
|
|
135
|
+
return True
|
|
136
|
+
return False
|
|
137
|
+
|
|
138
|
+
|
|
125
139
|
@dataclass(slots=True)
|
|
126
140
|
class _RenderState:
|
|
127
141
|
"""State of one rendering call: the recursion guard and this call's hidden-key numbering."""
|
|
@@ -169,6 +183,10 @@ class Redactor:
|
|
|
169
183
|
"""Report whether a whole value equals a registered exact secret, optionally up to letter case."""
|
|
170
184
|
return is_secret(value, self.known_secrets, ignore_case=ignore_case)
|
|
171
185
|
|
|
186
|
+
def contains_known_secret(self, text: str) -> bool:
|
|
187
|
+
"""Report whether any registered exact secret occurs in ``text``, ignoring letter case."""
|
|
188
|
+
return contains_secret(text, self.known_secrets)
|
|
189
|
+
|
|
172
190
|
def redact_text(self, value: str) -> str:
|
|
173
191
|
"""Scrub credential-bearing textual forms and apply a hard length bound."""
|
|
174
192
|
return self.render_text(value)
|
|
@@ -248,7 +248,9 @@ class ProtocolCodec:
|
|
|
248
248
|
if len(code) > _MAX_VALIDATION_TEXT:
|
|
249
249
|
# A code is cut only after redaction, like the texts above: cutting first would turn a known secret
|
|
250
250
|
# into a prefix that exact-secret redaction no longer recognizes.
|
|
251
|
-
code = render_code(code, redactor=self._redactor, context=diagnostics)[
|
|
251
|
+
code = render_code(code, redactor=self._redactor, context=diagnostics, v3_envelope=True)[
|
|
252
|
+
:_MAX_VALIDATION_TEXT
|
|
253
|
+
]
|
|
252
254
|
return code, SafeText(render(message)), tuple(bounded), truncated
|
|
253
255
|
|
|
254
256
|
@staticmethod
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: b24api
|
|
3
|
-
Version: 2.6.
|
|
3
|
+
Version: 2.6.1
|
|
4
4
|
Summary: Bitrix24 API
|
|
5
5
|
Author-email: Shkarupa Alex <shkarupa.alex@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -127,8 +127,9 @@ may already have reached Bitrix:
|
|
|
127
127
|
|
|
128
128
|
A failure that proves the request did not run is retried whatever its safety: a transport failure
|
|
129
129
|
before dispatch, or a refusal listed in `AmbiguityPolicy`, which by default is an unstructured 423, 425
|
|
130
|
-
or 429 (`refusal_http_statuses`) or a `QUERY_LIMIT_EXCEEDED` / `OPERATION_TIME_LIMIT`
|
|
131
|
-
(`refusal_api_codes`). A code or
|
|
130
|
+
or 429 (`refusal_http_statuses`) or a `QUERY_LIMIT_EXCEEDED` / `OPERATION_TIME_LIMIT` /
|
|
131
|
+
REST 3.0 `BITRIX_REST_V3_EXCEPTION_RATELIMITEXCEPTION` refusal (`refusal_api_codes`). A code or
|
|
132
|
+
status added only to `RetryPolicy` is retried for `SAFE` work alone.
|
|
132
133
|
A physical batch applies these rules to each command: after a failure, only the commands that
|
|
133
134
|
may run again are sent again, in a smaller batch, and an `UNSAFE` command of a batch that may have run
|
|
134
135
|
arrives as unknown. Replay rounds spend the same attempt and retry-time budget as the sends before
|
|
@@ -161,6 +162,42 @@ one_attempt = dataclasses.replace(ExecutionPolicy.from_settings(settings), max_a
|
|
|
161
162
|
result = await client.call(request, policy=one_attempt)
|
|
162
163
|
```
|
|
163
164
|
|
|
165
|
+
### Error codes
|
|
166
|
+
|
|
167
|
+
A structured refusal raises `ApiResponseError`. Its message, `wire_code`, `normalized_code`, `code`
|
|
168
|
+
(lower case) and `to_safe_dict()` name the server's code, so failures can be told apart:
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
API error [BITRIX_REST_V3_EXCEPTION_ACCESSDENIEDEXCEPTION]: Access denied
|
|
172
|
+
API error [NOTE_EMPTY_UPDATE]: Nothing to update
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
A REST 3.0 `error.code` is shown verbatim whenever it is a snake-case identifier: upper case, such
|
|
176
|
+
as `BITRIX_REST_V3_EXCEPTION_INVALIDSELECTEXCEPTION` or `FEATURE_NOT_AVAILABLE_ON_CURRENT_PLAN`, or
|
|
177
|
+
lower case of letters only, such as `invalid_select_field`; the server's set is open, so no list is
|
|
178
|
+
kept. Error texts, classic
|
|
179
|
+
`{"error": ...}` codes and response previews keep the conservative redaction, so a long run of
|
|
180
|
+
letters and digits there still renders as `[REDACTED]`. A code that equals or contains your
|
|
181
|
+
webhook token or a credential of the request, in any letter case, is always `[REDACTED]`; one that
|
|
182
|
+
names a field of your request is shown as its `field#N` alias, or as `[REDACTED]` when only its
|
|
183
|
+
letter case differs.
|
|
184
|
+
|
|
185
|
+
Recognizing a code does not make it retryable. By default only the REST 3.0 load limits are retried,
|
|
186
|
+
after the server's `Retry-After`:
|
|
187
|
+
|
|
188
|
+
| Code | Status | Retried |
|
|
189
|
+
|---|---|---|
|
|
190
|
+
| `BITRIX_REST_V3_EXCEPTION_RATELIMITEXCEPTION` | 429 | Any direct request: the limiter refuses before the method runs. In a REST 3.0 batch envelope only `SAFE` commands, as for any structured envelope error. |
|
|
191
|
+
| `BITRIX_REST_V3_EXCEPTION_LIMITER_QUERYTIMELIMITEXCEPTION` | 503 | `SAFE` requests only: the method may have run. |
|
|
192
|
+
|
|
193
|
+
Every other REST 3.0 code is a deterministic refusal and is raised at once, including a 429 or 503
|
|
194
|
+
that a module declares for a longer-lived state (`LANDING_AI_SITE_MODERATION_BLOCK_LIMIT`,
|
|
195
|
+
`LANDING_AI_MODULE_UNAVAILABLE`). List more codes in `RetryPolicy.transient_api_codes` (and in
|
|
196
|
+
`AmbiguityPolicy.refusal_api_codes` when the code proves the method did not run). The request
|
|
197
|
+
faults `BITRIX_REST_V3_EXCEPTION_VALIDATION_REQUESTVALIDATIONEXCEPTION` and
|
|
198
|
+
`BITRIX_REST_V3_EXCEPTION_METHODNOTFOUNDEXCEPTION` in a REST 3.0 error envelope are never retried,
|
|
199
|
+
even when listed.
|
|
200
|
+
|
|
164
201
|
## Logical batch and correlation
|
|
165
202
|
|
|
166
203
|
`batch()` accepts an arbitrary-length synchronous or asynchronous command source. It consumes the
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"""The closed set of REST 3.0 error codes b24api recognizes, and their one safe rendering.
|
|
2
|
-
|
|
3
|
-
The set is the single owner of V3 code knowledge: protocol classification reads it to decide
|
|
4
|
-
retryability and the error renderer reads it to decide which codes may be shown verbatim. Everything
|
|
5
|
-
outside it, including any other ``SCREAMING_SNAKE`` or ``BITRIX_REST_V3_*`` string, keeps the
|
|
6
|
-
conservative free-text redaction, because a caller credential may have the same shape. A new code is
|
|
7
|
-
one literal here plus one test.
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
from __future__ import annotations
|
|
11
|
-
from typing import TYPE_CHECKING
|
|
12
|
-
|
|
13
|
-
from b24api.redaction import DEFAULT_REDACTOR, REDACTED, Redactor
|
|
14
|
-
|
|
15
|
-
if TYPE_CHECKING:
|
|
16
|
-
from b24api._diagnostics import DiagnosticContext
|
|
17
|
-
|
|
18
|
-
VALIDATION_ERROR_CODE = "BITRIX_REST_V3_EXCEPTION_VALIDATION_REQUESTVALIDATIONEXCEPTION"
|
|
19
|
-
METHOD_NOT_FOUND_ERROR_CODE = "BITRIX_REST_V3_EXCEPTION_METHODNOTFOUNDEXCEPTION"
|
|
20
|
-
# Every known code is a deterministic request fault; a retryable code would join through its own subset.
|
|
21
|
-
NON_RETRYABLE_V3_ERROR_CODES = frozenset({VALIDATION_ERROR_CODE, METHOD_NOT_FOUND_ERROR_CODE})
|
|
22
|
-
KNOWN_V3_ERROR_CODES = NON_RETRYABLE_V3_ERROR_CODES
|
|
23
|
-
_KNOWN_FOLDED = frozenset(code.casefold() for code in KNOWN_V3_ERROR_CODES)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def is_known_v3_code(code: str) -> bool:
|
|
27
|
-
"""Report whether a wire code is one of the fixed known V3 literals, ignoring case only."""
|
|
28
|
-
return code.casefold() in _KNOWN_FOLDED
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def render_code(
|
|
32
|
-
code: str | int,
|
|
33
|
-
*,
|
|
34
|
-
redactor: Redactor = DEFAULT_REDACTOR,
|
|
35
|
-
context: DiagnosticContext | None = None,
|
|
36
|
-
) -> str:
|
|
37
|
-
"""Render one structured error code: exact secret, then known V3 literal, then free-text redaction.
|
|
38
|
-
|
|
39
|
-
Recognition never overrides an exact secret. Case folding is the only normalization, so the
|
|
40
|
-
lower-cased public ``code`` attribute of a known literal stays diagnosable; because recognition
|
|
41
|
-
ignores case, a secret equal up to case is redacted too. A longer or shorter string that merely
|
|
42
|
-
contains a known code is free text.
|
|
43
|
-
"""
|
|
44
|
-
text = str(code)
|
|
45
|
-
if redactor.is_known_secret(text, ignore_case=True) or (
|
|
46
|
-
context is not None and context.is_known_secret(text, ignore_case=True)
|
|
47
|
-
):
|
|
48
|
-
return REDACTED
|
|
49
|
-
if is_known_v3_code(text):
|
|
50
|
-
return text
|
|
51
|
-
return redactor.render_text(text, context=context)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
__all__ = [
|
|
55
|
-
"KNOWN_V3_ERROR_CODES",
|
|
56
|
-
"METHOD_NOT_FOUND_ERROR_CODE",
|
|
57
|
-
"NON_RETRYABLE_V3_ERROR_CODES",
|
|
58
|
-
"VALIDATION_ERROR_CODE",
|
|
59
|
-
"is_known_v3_code",
|
|
60
|
-
"render_code",
|
|
61
|
-
]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|