1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
//! The error envelope and the closed set of error codes.
//!
//! Every rejection the hub makes has the same shape:
//!
//! ```text
//! 422 { "errors": [ { "path": "results[0].metric", "code": "metric_id_invalid", "hint": "..." }, ... ] }
//! ```
//!
//! Validation collects *all* errors before returning, so a producer fixes a
//! record in one round trip rather than one error at a time. `path` is a
//! JSON-pointer-like location in the submitted record; `code` is one of the
//! variants below and is listed as an enum in the OpenAPI document; `hint`
//! is prose for a human and is not part of the contract.
//!
//! | Code | Status | Meaning |
//! | ------------------------ | ------ | -------------------------------------------------------------------- |
//! | `schema` | 422 | JSON Schema violation (unknown key, wrong type, missing required) |
//! | `number_too_large` | 422 | integer outside ±2^53 |
//! | `counts_missing` | 422 | `results` non-empty but no `counts` |
//! | `counts_inconsistent` | 422 | `attempted < completed + failed + skipped + errored` |
//! | `attachment_ref_unknown` | 422 | `samples_ref` / `calls` / `artifacts[]` / `error.log` not in `attachments[].path` |
//! | `attachment_path_invalid`| 422 | duplicate, `..`, or absolute `attachments[].path` |
//! | `metric_id_invalid` | 422 | `results[].metric`, `run_results[].metric` or a run's `metrics` key not of the form `{ns}/{name}` |
//! | `ext_key_invalid` | 422 | a key of `ext` (top-level or in a facet) not of the form `{ns}/{name}` |
//! | `type_mismatch` | 422 | query: operator applied to a path of another type |
//! | `not_indexed` | 422 | query: operator needs an index the path does not have |
//! | `unknown_path` | 422 | query: path not in the schema |
//! | `runs_moved` | 422 | an `evalhub.eval/2.0` header carries `runs`; runs are written apart |
//! | `run_status_detail` | 422 | `error` present iff `status` is `error`, `skip_reason` iff `skipped` |
//! | `run_id_invalid` | 422 | `run_id` empty, containing `/`, or over 200 bytes |
//! | `run_id_mismatch` | 422 | the `run_id` in the body differs from the one in the path |
//! | `run_result_value_or_label` | 422 | a `run_results[]` element has neither `value` nor `label` |
//! | `run_results_eval_unknown` | 422 | `run_results[].eval` is not the record of any `core/uses_eval` |
//! | `run_unknown` | 422 | a `run_id` in the used set has no row in that Eval |
//! | `run_not_in_used_set` | 422 | `run_results[].run_id` outside the Card's used set for its `eval` |
//! | `too_many_run_results` | 422 | more `run_results[]` than the configured limit |
//! | `batch_duplicate_run_id` | 422 | the same `run_id` twice in one batch |
//! | `attachment_missing` | 409 | `attachments[].sha256` not uploaded and confirmed |
//! | `label_in_use` | 409 | `@{label}` already names another version |
//! | `namespace_in_use` | 409 | the organisation slug is already a user or an organisation |
//! | `registry_entry_exists` | 409 | that registry address is taken; entries are immutable |
//! | `run_deleted` | 409 | writing a `run_id` that was deleted; a deleted id is never reused |
//! | `batch_too_large` | 413 | more runs in one batch than the configured count |
//! | `body_too_large` | 413 | request body over the configured size in bytes |
//!
//! A `413` carries this body only with the two `413` codes above. Other
//! statuses carry no body of this shape: `404` for anything the caller
//! may not know exists (including private records), `403` for a token
//! without the scope, `401` for no or an invalid token, `400` for a body that
//! is not JSON.
//!
//! Codes are added, never renamed or reused. A client switching on `code`
//! must treat an unknown code as a generic 422. The enum is
//! `#[non_exhaustive]` for the same reason: a release may add a code, and a
//! `match` in another crate must have a fallback arm for it.
use JsonSchema;
use ;
/// The closed set of error codes.
/// One rejection.
/// The body of every `422` and `409` response.