rn-forge-web 0.3.2__tar.gz → 0.4.0__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.
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/PKG-INFO +3 -3
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/pyproject.toml +9 -9
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/pyproject.toml.orig +9 -9
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/__init__.py +6 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_platform.py +5 -6
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_transfer.py +23 -18
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/exceptions.py +15 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/problem.py +7 -3
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/transfer.py +57 -45
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/LICENSE +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/README.md +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/asgi.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/auth.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/concurrency.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/__init__.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_pagination.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_problem.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_shared.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_writes.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/cases.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/types.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/deprecation.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/health.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/idempotency.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/merge_patch.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/models.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/openapi.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/operations.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/pagination.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/py.typed +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/read_mask.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/security.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/soft_delete.py +0 -0
- {rn_forge_web-0.3.2 → rn_forge_web-0.4.0}/src/rn_forge/web/tracing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rn-forge-web
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Framework-agnostic HTTP/API primitives built on rn-forge-commons
|
|
5
5
|
Author: Rohit Narayanan
|
|
6
6
|
Author-email: Rohit Narayanan <rohit.nn@gmail.com>
|
|
@@ -15,8 +15,8 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
15
15
|
Classifier: Typing :: Typed
|
|
16
16
|
Requires-Dist: rn-forge-commons[pydantic]>=0.8.0,<0.11
|
|
17
17
|
Requires-Dist: opentelemetry-api>=1.44
|
|
18
|
-
Requires-Dist: secure>=2.0.
|
|
19
|
-
Requires-Dist: assertpy>=2.
|
|
18
|
+
Requires-Dist: secure>=2.0.2 ; extra == 'security'
|
|
19
|
+
Requires-Dist: assertpy>=2.36.0 ; extra == 'testing'
|
|
20
20
|
Requires-Dist: pytest>=9.1.1 ; extra == 'testing'
|
|
21
21
|
Requires-Python: >=3.14
|
|
22
22
|
Project-URL: Documentation, https://rn-forge.github.io/pykit/packages/rn-forge-web/latest/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "rn-forge-web"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Framework-agnostic HTTP/API primitives built on rn-forge-commons"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -26,10 +26,10 @@ email = "rohit.nn@gmail.com"
|
|
|
26
26
|
|
|
27
27
|
[project.optional-dependencies]
|
|
28
28
|
testing = [
|
|
29
|
-
"assertpy>=2.
|
|
29
|
+
"assertpy>=2.36.0",
|
|
30
30
|
"pytest>=9.1.1",
|
|
31
31
|
]
|
|
32
|
-
security = ["secure>=2.0.
|
|
32
|
+
security = ["secure>=2.0.2"]
|
|
33
33
|
|
|
34
34
|
[project.urls]
|
|
35
35
|
Documentation = "https://rn-forge.github.io/pykit/packages/rn-forge-web/latest/"
|
|
@@ -68,22 +68,22 @@ markers = ["unit: fast isolated tests"]
|
|
|
68
68
|
|
|
69
69
|
[dependency-groups]
|
|
70
70
|
dev = [
|
|
71
|
-
"assertpy>=2.
|
|
71
|
+
"assertpy>=2.36.0",
|
|
72
72
|
"opentelemetry-instrumentation-asgi>=0.65b0",
|
|
73
73
|
"opentelemetry-sdk>=1.44",
|
|
74
74
|
"pyright>=1.1.411",
|
|
75
|
-
"pytest>=9.
|
|
76
|
-
"pytest-asyncio>=1.
|
|
75
|
+
"pytest>=9.2.0",
|
|
76
|
+
"pytest-asyncio>=1.4.1.post1",
|
|
77
77
|
"pytest-cov>=7.1.0",
|
|
78
78
|
"pytest-randomly>=4.1.0",
|
|
79
79
|
"rn-forge-auth>=0.1.0,<0.3",
|
|
80
80
|
"rn-forge-web[security]",
|
|
81
|
-
"ruff>=0.
|
|
81
|
+
"ruff>=0.17.4",
|
|
82
82
|
]
|
|
83
83
|
docs = [
|
|
84
84
|
"mkdocs>=1.6.1",
|
|
85
|
-
"mkdocs-material>=9.
|
|
86
|
-
"mkdocstrings[python]>=1.0.
|
|
85
|
+
"mkdocs-material>=9.8.1",
|
|
86
|
+
"mkdocstrings[python]>=1.0.8",
|
|
87
87
|
"opentelemetry-instrumentation-asgi>=0.65b0",
|
|
88
88
|
"rn-forge-auth>=0.1.0,<0.3",
|
|
89
89
|
"rn-forge-web[security]",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "rn-forge-web"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Framework-agnostic HTTP/API primitives built on rn-forge-commons"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Rohit Narayanan", email = "rohit.nn@gmail.com" }]
|
|
@@ -27,11 +27,11 @@ dependencies = [
|
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
[project.optional-dependencies]
|
|
30
|
-
testing = ["assertpy>=2.
|
|
30
|
+
testing = ["assertpy>=2.36.0", "pytest>=9.1.1"]
|
|
31
31
|
# `rn_forge.web.security` only. `secure` is framework-agnostic (no dependencies
|
|
32
32
|
# of its own) and emits the OWASP header preset directly, so it is wrapped
|
|
33
33
|
# rather than hand-rolled.
|
|
34
|
-
security = ["secure>=2.0.
|
|
34
|
+
security = ["secure>=2.0.2"]
|
|
35
35
|
|
|
36
36
|
[project.urls]
|
|
37
37
|
Documentation = "https://rn-forge.github.io/pykit/packages/rn-forge-web/latest/"
|
|
@@ -66,23 +66,23 @@ markers = ["unit: fast isolated tests"]
|
|
|
66
66
|
|
|
67
67
|
[dependency-groups]
|
|
68
68
|
dev = [
|
|
69
|
-
"assertpy>=2.
|
|
69
|
+
"assertpy>=2.36.0",
|
|
70
70
|
"opentelemetry-instrumentation-asgi>=0.65b0",
|
|
71
71
|
"opentelemetry-sdk>=1.44",
|
|
72
72
|
"pyright>=1.1.411",
|
|
73
|
-
"pytest>=9.
|
|
74
|
-
"pytest-asyncio>=1.
|
|
73
|
+
"pytest>=9.2.0",
|
|
74
|
+
"pytest-asyncio>=1.4.1.post1",
|
|
75
75
|
"pytest-cov>=7.1.0",
|
|
76
76
|
"pytest-randomly>=4.1.0",
|
|
77
77
|
# The guide examples, which the tests run, import rn-forge-auth.
|
|
78
78
|
"rn-forge-auth>=0.1.0,<0.3",
|
|
79
79
|
"rn-forge-web[security]",
|
|
80
|
-
"ruff>=0.
|
|
80
|
+
"ruff>=0.17.4",
|
|
81
81
|
]
|
|
82
82
|
docs = [
|
|
83
83
|
"mkdocs>=1.6.1",
|
|
84
|
-
"mkdocs-material>=9.
|
|
85
|
-
"mkdocstrings[python]>=1.0.
|
|
84
|
+
"mkdocs-material>=9.8.1",
|
|
85
|
+
"mkdocstrings[python]>=1.0.8",
|
|
86
86
|
"opentelemetry-instrumentation-asgi>=0.65b0",
|
|
87
87
|
"rn-forge-auth>=0.1.0,<0.3",
|
|
88
88
|
"rn-forge-web[security]",
|
|
@@ -43,6 +43,7 @@ from rn_forge.web.deprecation import (
|
|
|
43
43
|
)
|
|
44
44
|
from rn_forge.web.exceptions import (
|
|
45
45
|
AuthenticationFailed,
|
|
46
|
+
BadRequest,
|
|
46
47
|
ContentTooLarge,
|
|
47
48
|
CsrfFailed,
|
|
48
49
|
DomainConflict,
|
|
@@ -56,6 +57,7 @@ from rn_forge.web.exceptions import (
|
|
|
56
57
|
InvalidReadMask,
|
|
57
58
|
ItemsDenied,
|
|
58
59
|
MalformedPrecondition,
|
|
60
|
+
NotFound,
|
|
59
61
|
PermissionDenied,
|
|
60
62
|
PreconditionRequired,
|
|
61
63
|
RemoteProblem,
|
|
@@ -66,6 +68,7 @@ from rn_forge.web.exceptions import (
|
|
|
66
68
|
SessionRequired,
|
|
67
69
|
TooManyRequests,
|
|
68
70
|
UnsupportedMediaType,
|
|
71
|
+
ValidationFailed,
|
|
69
72
|
VersionConflict,
|
|
70
73
|
WebError,
|
|
71
74
|
)
|
|
@@ -249,6 +252,7 @@ __all__ = [
|
|
|
249
252
|
"ASGIApp",
|
|
250
253
|
"AsyncIdempotencyStore",
|
|
251
254
|
"AuthenticationFailed",
|
|
255
|
+
"BadRequest",
|
|
252
256
|
"BatchUpdateItem",
|
|
253
257
|
"BearerErrorCode",
|
|
254
258
|
"BodySizeLimitMiddleware",
|
|
@@ -285,6 +289,7 @@ __all__ = [
|
|
|
285
289
|
"JsonValue",
|
|
286
290
|
"MalformedPrecondition",
|
|
287
291
|
"Message",
|
|
292
|
+
"NotFound",
|
|
288
293
|
"Operation",
|
|
289
294
|
"OrderField",
|
|
290
295
|
"Page",
|
|
@@ -311,6 +316,7 @@ __all__ = [
|
|
|
311
316
|
"TabularFormat",
|
|
312
317
|
"TooManyRequests",
|
|
313
318
|
"UnsupportedMediaType",
|
|
319
|
+
"ValidationFailed",
|
|
314
320
|
"VersionConflict",
|
|
315
321
|
"VersionETagCodec",
|
|
316
322
|
"WebError",
|
|
@@ -28,6 +28,7 @@ _TRACEPARENT: Final = "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01"
|
|
|
28
28
|
_READYZ_PATH: Final = "/conformance/readyz"
|
|
29
29
|
|
|
30
30
|
_ECHO_PATH: Final = "/conformance/echo"
|
|
31
|
+
_ORIGIN: Final = "https://example.com"
|
|
31
32
|
|
|
32
33
|
PLATFORM_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
33
34
|
ConformanceCase(
|
|
@@ -263,13 +264,11 @@ PLATFORM_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
263
264
|
"configured order. traceresponse is exposed by the OpenTelemetry "
|
|
264
265
|
"response propagator itself, not by this list."
|
|
265
266
|
),
|
|
266
|
-
request=RequestSpec(
|
|
267
|
-
"GET", _ECHO_PATH, headers={"Origin": "https://example.com"}
|
|
268
|
-
),
|
|
267
|
+
request=RequestSpec("GET", _ECHO_PATH, headers={"Origin": _ORIGIN}),
|
|
269
268
|
expect_status=200,
|
|
270
269
|
expect_headers={
|
|
271
270
|
**_JSON,
|
|
272
|
-
"Access-Control-Allow-Origin":
|
|
271
|
+
"Access-Control-Allow-Origin": _ORIGIN,
|
|
273
272
|
"Access-Control-Expose-Headers": ", ".join(
|
|
274
273
|
(*EXPOSED_HEADERS, "traceresponse")
|
|
275
274
|
),
|
|
@@ -286,10 +285,10 @@ PLATFORM_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
286
285
|
request=RequestSpec(
|
|
287
286
|
"GET",
|
|
288
287
|
"/conformance/orders",
|
|
289
|
-
headers={"Accept": _CSV_TYPE, "Origin":
|
|
288
|
+
headers={"Accept": _CSV_TYPE, "Origin": _ORIGIN},
|
|
290
289
|
),
|
|
291
290
|
expect_status=200,
|
|
292
|
-
expect_headers={"Access-Control-Allow-Origin":
|
|
291
|
+
expect_headers={"Access-Control-Allow-Origin": _ORIGIN},
|
|
293
292
|
expect_header_patterns={
|
|
294
293
|
"Content-Type": _CSV_TYPE_PATTERN,
|
|
295
294
|
"Access-Control-Expose-Headers": r"(.+, )?Content-Disposition(, .+)?",
|
|
@@ -27,6 +27,11 @@ from rn_forge.web.problem import (
|
|
|
27
27
|
__all__ = ["TRANSFER_CASES"]
|
|
28
28
|
|
|
29
29
|
_BOOKS_UPDATE: Final = "/conformance/books:batchUpdate"
|
|
30
|
+
_ORDERS_IMPORT: Final = "/conformance/orders:import"
|
|
31
|
+
_MULTIPART: Final = "multipart/form-data"
|
|
32
|
+
_ROWS_INVALID: Final = "One or more rows are invalid."
|
|
33
|
+
_ORDERS_BATCH_CREATE: Final = "/conformance/orders:batchCreate"
|
|
34
|
+
_VALIDATION_ERROR: Final = "Validation Error"
|
|
30
35
|
|
|
31
36
|
_STALE_BOOK: Final = "Precondition failed: expected version 1, got 9"
|
|
32
37
|
|
|
@@ -107,8 +112,8 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
107
112
|
),
|
|
108
113
|
request=RequestSpec(
|
|
109
114
|
"POST",
|
|
110
|
-
|
|
111
|
-
headers={"Content-Type":
|
|
115
|
+
_ORDERS_IMPORT,
|
|
116
|
+
headers={"Content-Type": _MULTIPART},
|
|
112
117
|
query={"validateOnly": "true"},
|
|
113
118
|
body={"file": "id,name,Quantity\n2,gadget,3\n"},
|
|
114
119
|
),
|
|
@@ -125,15 +130,15 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
125
130
|
),
|
|
126
131
|
request=RequestSpec(
|
|
127
132
|
"POST",
|
|
128
|
-
|
|
129
|
-
headers={"Content-Type":
|
|
133
|
+
_ORDERS_IMPORT,
|
|
134
|
+
headers={"Content-Type": _MULTIPART},
|
|
130
135
|
body={"file": "id,name,Quantity\n2,gadget,three\n"},
|
|
131
136
|
),
|
|
132
137
|
expect_status=422,
|
|
133
138
|
expect_headers=_PROBLEM,
|
|
134
139
|
expect_body=_problem_body(
|
|
135
140
|
VALIDATION_ERROR,
|
|
136
|
-
|
|
141
|
+
_ROWS_INVALID,
|
|
137
142
|
errors=[{"pointer": "/rows/0/Quantity", "detail": "Enter a whole number."}],
|
|
138
143
|
),
|
|
139
144
|
),
|
|
@@ -146,7 +151,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
146
151
|
),
|
|
147
152
|
request=RequestSpec(
|
|
148
153
|
"POST",
|
|
149
|
-
|
|
154
|
+
_ORDERS_BATCH_CREATE,
|
|
150
155
|
headers=_JSON,
|
|
151
156
|
body={"requests": [{"name": "ok"}, {}]},
|
|
152
157
|
),
|
|
@@ -154,7 +159,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
154
159
|
expect_headers=_PROBLEM,
|
|
155
160
|
expect_body=_problem_body(
|
|
156
161
|
VALIDATION_ERROR,
|
|
157
|
-
|
|
162
|
+
_ROWS_INVALID,
|
|
158
163
|
errors=[
|
|
159
164
|
{"pointer": "/requests/1/name", "detail": "This field is required."}
|
|
160
165
|
],
|
|
@@ -176,7 +181,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
176
181
|
description="AIP-233: a successful batch is 200 with the created resources under the plural name.",
|
|
177
182
|
request=RequestSpec(
|
|
178
183
|
"POST",
|
|
179
|
-
|
|
184
|
+
_ORDERS_BATCH_CREATE,
|
|
180
185
|
headers=_JSON,
|
|
181
186
|
body={"requests": [{"name": "gadget"}]},
|
|
182
187
|
),
|
|
@@ -261,15 +266,15 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
261
266
|
description="A multipart import with no file part is a 422 naming /file.",
|
|
262
267
|
request=RequestSpec(
|
|
263
268
|
"POST",
|
|
264
|
-
|
|
265
|
-
headers={"Content-Type":
|
|
269
|
+
_ORDERS_IMPORT,
|
|
270
|
+
headers={"Content-Type": _MULTIPART},
|
|
266
271
|
body={},
|
|
267
272
|
),
|
|
268
273
|
expect_status=422,
|
|
269
274
|
expect_headers=_PROBLEM,
|
|
270
275
|
expect_body=_problem_body(
|
|
271
276
|
VALIDATION_ERROR,
|
|
272
|
-
|
|
277
|
+
_VALIDATION_ERROR,
|
|
273
278
|
errors=[{"pointer": "/file", "detail": "This field is required."}],
|
|
274
279
|
),
|
|
275
280
|
),
|
|
@@ -280,7 +285,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
280
285
|
request=RequestSpec(
|
|
281
286
|
"POST",
|
|
282
287
|
"/conformance/capped:import",
|
|
283
|
-
headers={"Content-Type":
|
|
288
|
+
headers={"Content-Type": _MULTIPART},
|
|
284
289
|
body={"file": "id,name,Quantity\n2,a,3\n3,b,4\n"},
|
|
285
290
|
),
|
|
286
291
|
expect_status=422,
|
|
@@ -295,7 +300,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
295
300
|
description="AIP-233: an empty requests list is a 422 naming /requests.",
|
|
296
301
|
request=RequestSpec(
|
|
297
302
|
"POST",
|
|
298
|
-
|
|
303
|
+
_ORDERS_BATCH_CREATE,
|
|
299
304
|
headers=_JSON,
|
|
300
305
|
body={"requests": []},
|
|
301
306
|
),
|
|
@@ -303,7 +308,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
303
308
|
expect_headers=_PROBLEM,
|
|
304
309
|
expect_body=_problem_body(
|
|
305
310
|
VALIDATION_ERROR,
|
|
306
|
-
|
|
311
|
+
_VALIDATION_ERROR,
|
|
307
312
|
errors=[
|
|
308
313
|
{"pointer": "/requests", "detail": "A non-empty list is required."}
|
|
309
314
|
],
|
|
@@ -334,7 +339,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
334
339
|
),
|
|
335
340
|
request=RequestSpec(
|
|
336
341
|
"POST",
|
|
337
|
-
|
|
342
|
+
_ORDERS_BATCH_CREATE,
|
|
338
343
|
headers=_JSON,
|
|
339
344
|
body={"requests": [{"name": "ok"}, {"name": "forbidden"}]},
|
|
340
345
|
),
|
|
@@ -469,7 +474,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
469
474
|
expect_headers=_PROBLEM,
|
|
470
475
|
expect_body=_problem_body(
|
|
471
476
|
VALIDATION_ERROR,
|
|
472
|
-
|
|
477
|
+
_ROWS_INVALID,
|
|
473
478
|
errors=[{"pointer": "/requests/0/patch/name", "detail": NULL_FIELD_DETAIL}],
|
|
474
479
|
),
|
|
475
480
|
),
|
|
@@ -501,7 +506,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
501
506
|
expect_headers=_PROBLEM,
|
|
502
507
|
expect_body=_problem_body(
|
|
503
508
|
VALIDATION_ERROR,
|
|
504
|
-
|
|
509
|
+
_ROWS_INVALID,
|
|
505
510
|
errors=[{"pointer": "/requests/1/id", "detail": "Duplicate id in batch."}],
|
|
506
511
|
),
|
|
507
512
|
),
|
|
@@ -516,7 +521,7 @@ TRANSFER_CASES: Final[tuple[ConformanceCase, ...]] = (
|
|
|
516
521
|
expect_headers=_PROBLEM,
|
|
517
522
|
expect_body=_problem_body(
|
|
518
523
|
VALIDATION_ERROR,
|
|
519
|
-
|
|
524
|
+
_VALIDATION_ERROR,
|
|
520
525
|
errors=[
|
|
521
526
|
{"pointer": "/requests", "detail": "A non-empty list is required."}
|
|
522
527
|
],
|
|
@@ -13,6 +13,7 @@ if TYPE_CHECKING:
|
|
|
13
13
|
|
|
14
14
|
__all__ = [
|
|
15
15
|
"AuthenticationFailed",
|
|
16
|
+
"BadRequest",
|
|
16
17
|
"ContentTooLarge",
|
|
17
18
|
"CsrfFailed",
|
|
18
19
|
"DomainConflict",
|
|
@@ -26,6 +27,7 @@ __all__ = [
|
|
|
26
27
|
"InvalidReadMask",
|
|
27
28
|
"ItemsDenied",
|
|
28
29
|
"MalformedPrecondition",
|
|
30
|
+
"NotFound",
|
|
29
31
|
"PermissionDenied",
|
|
30
32
|
"PreconditionRequired",
|
|
31
33
|
"RemoteProblem",
|
|
@@ -36,6 +38,7 @@ __all__ = [
|
|
|
36
38
|
"SessionRequired",
|
|
37
39
|
"TooManyRequests",
|
|
38
40
|
"UnsupportedMediaType",
|
|
41
|
+
"ValidationFailed",
|
|
39
42
|
"VersionConflict",
|
|
40
43
|
"WebError",
|
|
41
44
|
]
|
|
@@ -118,6 +121,18 @@ class MalformedPrecondition(_PointedError):
|
|
|
118
121
|
"""The precondition header was present but could not be parsed (400)."""
|
|
119
122
|
|
|
120
123
|
|
|
124
|
+
class BadRequest(_PointedError):
|
|
125
|
+
"""The request cannot be read as sent (400)."""
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class NotFound(WebError):
|
|
129
|
+
"""The addressed resource does not exist, or its existence is hidden (404)."""
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class ValidationFailed(_PointedError):
|
|
133
|
+
"""The request is well formed but breaks a rule (422)."""
|
|
134
|
+
|
|
135
|
+
|
|
121
136
|
class InvalidCursor(WebError):
|
|
122
137
|
"""The pagination token was absent from, or malformed in, the request (400)."""
|
|
123
138
|
|
|
@@ -18,6 +18,7 @@ from pydantic import ConfigDict, model_validator
|
|
|
18
18
|
from rn_forge.web.auth import AUTH_FAILED_DETAIL, CSRF_FAILED_DETAIL, challenge_header
|
|
19
19
|
from rn_forge.web.exceptions import (
|
|
20
20
|
AuthenticationFailed,
|
|
21
|
+
BadRequest,
|
|
21
22
|
ContentTooLarge,
|
|
22
23
|
CsrfFailed,
|
|
23
24
|
DomainConflict,
|
|
@@ -31,6 +32,7 @@ from rn_forge.web.exceptions import (
|
|
|
31
32
|
InvalidReadMask,
|
|
32
33
|
ItemsDenied,
|
|
33
34
|
MalformedPrecondition,
|
|
35
|
+
NotFound,
|
|
34
36
|
PermissionDenied,
|
|
35
37
|
PreconditionRequired,
|
|
36
38
|
RemoteProblem,
|
|
@@ -38,6 +40,7 @@ from rn_forge.web.exceptions import (
|
|
|
38
40
|
ServiceUnavailable,
|
|
39
41
|
TooManyRequests,
|
|
40
42
|
UnsupportedMediaType,
|
|
43
|
+
ValidationFailed,
|
|
41
44
|
VersionConflict,
|
|
42
45
|
)
|
|
43
46
|
from rn_forge.web.models import WireModel
|
|
@@ -302,7 +305,7 @@ class ProblemRegistry:
|
|
|
302
305
|
|
|
303
306
|
A framework raises HTTP errors no application registered — a routing
|
|
304
307
|
404, a 405. The row is the **first registered row with that status**, so
|
|
305
|
-
a framework 404 and a ``
|
|
308
|
+
a framework 404 and a ``NotFound`` produce the same body. With no such
|
|
306
309
|
row it is derived from the IANA reason phrase (405 →
|
|
307
310
|
``method-not-allowed`` / ``Method Not Allowed``); a status with no
|
|
308
311
|
reason phrase resolves to the fallback.
|
|
@@ -543,8 +546,9 @@ def default_registry(*, type_base: str = "") -> ProblemRegistry:
|
|
|
543
546
|
.register(InvalidMergePatch, VALIDATION_ERROR)
|
|
544
547
|
.register(RowsInvalid, VALIDATION_ERROR)
|
|
545
548
|
.register(ServiceUnavailable, SERVICE_UNAVAILABLE)
|
|
546
|
-
.register(
|
|
547
|
-
.register(
|
|
549
|
+
.register(BadRequest, BAD_REQUEST)
|
|
550
|
+
.register(NotFound, NOT_FOUND)
|
|
551
|
+
.register(ValidationFailed, VALIDATION_ERROR)
|
|
548
552
|
)
|
|
549
553
|
|
|
550
554
|
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from collections.abc import Iterable, Mapping
|
|
5
|
+
from collections.abc import Iterable, Mapping, Sequence
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from typing import Any, Final, Literal, cast
|
|
8
8
|
from urllib.parse import quote
|
|
9
9
|
|
|
10
|
-
from rn_forge.web.exceptions import InvalidBatchGet, RowsInvalid
|
|
10
|
+
from rn_forge.web.exceptions import InvalidBatchGet, RowsInvalid, ValidationFailed
|
|
11
11
|
from rn_forge.web.merge_patch import JsonValue
|
|
12
12
|
from rn_forge.web.problem import (
|
|
13
13
|
REQUIRED_FIELD_DETAIL,
|
|
@@ -51,6 +51,7 @@ DUPLICATE_ID_DETAIL: Final = "Duplicate id in batch."
|
|
|
51
51
|
"""The detail for a repeated id in a ``:batchUpdate`` request."""
|
|
52
52
|
|
|
53
53
|
_PATCH_DETAIL: Final = "A merge patch must be a JSON object."
|
|
54
|
+
_VALIDATION_ERROR: Final = "Validation Error"
|
|
54
55
|
_IF_MATCH_DETAIL: Final = "Not a valid string."
|
|
55
56
|
|
|
56
57
|
|
|
@@ -207,7 +208,7 @@ def row_errors_problem(
|
|
|
207
208
|
]
|
|
208
209
|
return render_problem(
|
|
209
210
|
registry or default_registry(),
|
|
210
|
-
|
|
211
|
+
ValidationFailed(_VALIDATION_ERROR),
|
|
211
212
|
instance=instance,
|
|
212
213
|
problem=VALIDATION_ERROR,
|
|
213
214
|
detail="One or more rows are invalid.",
|
|
@@ -221,7 +222,7 @@ def export_cap_problem(
|
|
|
221
222
|
"""Render "the export exceeds *cap* rows" as a 422 problem naming the cap."""
|
|
222
223
|
return render_problem(
|
|
223
224
|
registry or default_registry(),
|
|
224
|
-
|
|
225
|
+
ValidationFailed(_VALIDATION_ERROR),
|
|
225
226
|
instance=instance,
|
|
226
227
|
problem=VALIDATION_ERROR,
|
|
227
228
|
detail=f"The export exceeds the limit of {cap} rows; narrow the filter.",
|
|
@@ -245,7 +246,7 @@ def row_cap_problem(
|
|
|
245
246
|
"""
|
|
246
247
|
return render_problem(
|
|
247
248
|
registry or default_registry(),
|
|
248
|
-
|
|
249
|
+
ValidationFailed(_VALIDATION_ERROR),
|
|
249
250
|
instance=instance,
|
|
250
251
|
problem=VALIDATION_ERROR,
|
|
251
252
|
detail=_cap_detail(kind, cap),
|
|
@@ -291,6 +292,54 @@ class BatchUpdateItem:
|
|
|
291
292
|
if_match: str | None
|
|
292
293
|
|
|
293
294
|
|
|
295
|
+
def _parse_batch_item(
|
|
296
|
+
index: int, entry: object, errors: list[RowError]
|
|
297
|
+
) -> BatchUpdateItem | None:
|
|
298
|
+
fields = cast("dict[str, object]", entry) if isinstance(entry, dict) else {}
|
|
299
|
+
item_id = fields.get("id")
|
|
300
|
+
patch = fields.get("patch")
|
|
301
|
+
if_match = fields.get("ifMatch")
|
|
302
|
+
failed = False
|
|
303
|
+
if isinstance(item_id, bool) or not isinstance(item_id, (str, int)):
|
|
304
|
+
errors.append(RowError(index, "id", REQUIRED_FIELD_DETAIL))
|
|
305
|
+
failed = True
|
|
306
|
+
if not isinstance(patch, dict):
|
|
307
|
+
errors.append(RowError(index, "patch", _PATCH_DETAIL))
|
|
308
|
+
failed = True
|
|
309
|
+
if if_match is not None and not isinstance(if_match, str):
|
|
310
|
+
errors.append(RowError(index, "ifMatch", _IF_MATCH_DETAIL))
|
|
311
|
+
failed = True
|
|
312
|
+
if failed:
|
|
313
|
+
return None
|
|
314
|
+
return BatchUpdateItem(
|
|
315
|
+
index,
|
|
316
|
+
str(item_id),
|
|
317
|
+
cast("dict[str, JsonValue]", patch),
|
|
318
|
+
cast("str | None", if_match),
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def _parse_batch_items(entries: Sequence[object]) -> list[BatchUpdateItem]:
|
|
323
|
+
"""The items of a batch, in request order."""
|
|
324
|
+
items: list[BatchUpdateItem] = []
|
|
325
|
+
errors: list[RowError] = []
|
|
326
|
+
for index, entry in enumerate(entries):
|
|
327
|
+
item = _parse_batch_item(index, entry, errors)
|
|
328
|
+
if item is not None:
|
|
329
|
+
items.append(item)
|
|
330
|
+
if errors:
|
|
331
|
+
raise RowsInvalid(errors, root="requests")
|
|
332
|
+
|
|
333
|
+
seen: set[str] = set()
|
|
334
|
+
for item in items:
|
|
335
|
+
if item.id in seen:
|
|
336
|
+
errors.append(RowError(item.index, "id", DUPLICATE_ID_DETAIL))
|
|
337
|
+
seen.add(item.id)
|
|
338
|
+
if errors:
|
|
339
|
+
raise RowsInvalid(errors, root="requests")
|
|
340
|
+
return items
|
|
341
|
+
|
|
342
|
+
|
|
294
343
|
def parse_batch_update(
|
|
295
344
|
body: object,
|
|
296
345
|
*,
|
|
@@ -325,53 +374,16 @@ def parse_batch_update(
|
|
|
325
374
|
)
|
|
326
375
|
return render_problem(
|
|
327
376
|
registry or default_registry(),
|
|
328
|
-
|
|
377
|
+
ValidationFailed(_VALIDATION_ERROR),
|
|
329
378
|
instance=instance,
|
|
330
379
|
problem=VALIDATION_ERROR,
|
|
331
|
-
detail=
|
|
380
|
+
detail=_VALIDATION_ERROR,
|
|
332
381
|
extensions={"errors": [field_error(("requests",), detail)]},
|
|
333
382
|
)
|
|
334
383
|
entries = cast("list[object]", raw)
|
|
335
384
|
if cap is not None and len(entries) > cap:
|
|
336
385
|
return row_cap_problem("batch", cap, instance=instance, registry=registry)
|
|
337
|
-
|
|
338
|
-
items: list[BatchUpdateItem] = []
|
|
339
|
-
errors: list[RowError] = []
|
|
340
|
-
for index, entry in enumerate(entries):
|
|
341
|
-
fields = cast("dict[str, object]", entry) if isinstance(entry, dict) else {}
|
|
342
|
-
item_id = fields.get("id")
|
|
343
|
-
patch = fields.get("patch")
|
|
344
|
-
if_match = fields.get("ifMatch")
|
|
345
|
-
failed = False
|
|
346
|
-
if isinstance(item_id, bool) or not isinstance(item_id, (str, int)):
|
|
347
|
-
errors.append(RowError(index, "id", REQUIRED_FIELD_DETAIL))
|
|
348
|
-
failed = True
|
|
349
|
-
if not isinstance(patch, dict):
|
|
350
|
-
errors.append(RowError(index, "patch", _PATCH_DETAIL))
|
|
351
|
-
failed = True
|
|
352
|
-
if if_match is not None and not isinstance(if_match, str):
|
|
353
|
-
errors.append(RowError(index, "ifMatch", _IF_MATCH_DETAIL))
|
|
354
|
-
failed = True
|
|
355
|
-
if not failed:
|
|
356
|
-
items.append(
|
|
357
|
-
BatchUpdateItem(
|
|
358
|
-
index,
|
|
359
|
-
str(item_id),
|
|
360
|
-
cast("dict[str, JsonValue]", patch),
|
|
361
|
-
cast("str | None", if_match),
|
|
362
|
-
)
|
|
363
|
-
)
|
|
364
|
-
if errors:
|
|
365
|
-
raise RowsInvalid(errors, root="requests")
|
|
366
|
-
|
|
367
|
-
seen: set[str] = set()
|
|
368
|
-
for item in items:
|
|
369
|
-
if item.id in seen:
|
|
370
|
-
errors.append(RowError(item.index, "id", DUPLICATE_ID_DETAIL))
|
|
371
|
-
seen.add(item.id)
|
|
372
|
-
if errors:
|
|
373
|
-
raise RowsInvalid(errors, root="requests")
|
|
374
|
-
return items
|
|
386
|
+
return _parse_batch_items(entries)
|
|
375
387
|
|
|
376
388
|
|
|
377
389
|
@dataclass(frozen=True)
|
|
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
|