Skip to main content

aube_codes/
errors.rs

1//! Error codes (`ERR_AUBE_*`).
2//!
3//! Each constant's *value* matches its identifier. The `ALL` slice
4//! is the registry — it gates the generated docs page
5//! (`docs/error-codes.md`, produced by the
6//! `generate-error-codes-docs` binary) and the self-tests in
7//! `lib.rs`. New codes go in both places: define a `pub const`,
8//! then add a [`crate::CodeMeta`] entry to `ALL` carrying the
9//! category, one-line description, and (optional) bespoke exit
10//! code.
11
12use crate::CodeMeta;
13
14// ── lockfile ─────────────────────────────────────────────────────────
15pub const ERR_AUBE_NO_LOCKFILE: &str = "ERR_AUBE_NO_LOCKFILE";
16pub const ERR_AUBE_LOCKFILE_PARSE: &str = "ERR_AUBE_LOCKFILE_PARSE";
17pub const ERR_AUBE_LOCKFILE_UNSUPPORTED_FORMAT: &str = "ERR_AUBE_LOCKFILE_UNSUPPORTED_FORMAT";
18
19// ── resolver ─────────────────────────────────────────────────────────
20pub const ERR_AUBE_NO_MATCHING_VERSION: &str = "ERR_AUBE_NO_MATCHING_VERSION";
21pub const ERR_AUBE_NO_MATURE_MATCHING_VERSION: &str = "ERR_AUBE_NO_MATURE_MATCHING_VERSION";
22pub const ERR_AUBE_REGISTRY_ERROR: &str = "ERR_AUBE_REGISTRY_ERROR";
23pub const ERR_AUBE_UNKNOWN_CATALOG: &str = "ERR_AUBE_UNKNOWN_CATALOG";
24pub const ERR_AUBE_UNKNOWN_CATALOG_ENTRY: &str = "ERR_AUBE_UNKNOWN_CATALOG_ENTRY";
25pub const ERR_AUBE_BLOCKED_EXOTIC_SUBDEP: &str = "ERR_AUBE_BLOCKED_EXOTIC_SUBDEP";
26pub const ERR_AUBE_TRUST_DOWNGRADE: &str = "ERR_AUBE_TRUST_DOWNGRADE";
27pub const ERR_AUBE_TRUST_MISSING_TIME: &str = "ERR_AUBE_TRUST_MISSING_TIME";
28// `#[rustfmt::skip]` keeps the long names on a single visual line so the
29// declaration list reads as a flat table — rustfmt would otherwise wrap
30// to a `name: &str =\n    "name";` two-liner for any const past col 100.
31#[rustfmt::skip] pub const ERR_AUBE_TRUST_EXCLUDE_INVALID_VERSION_UNION: &str = "ERR_AUBE_TRUST_EXCLUDE_INVALID_VERSION_UNION";
32#[rustfmt::skip] pub const ERR_AUBE_TRUST_EXCLUDE_NAME_GLOB_WITH_VERSIONS: &str = "ERR_AUBE_TRUST_EXCLUDE_NAME_GLOB_WITH_VERSIONS";
33pub const ERR_AUBE_PEER_CONTEXT_NOT_CONVERGED: &str = "ERR_AUBE_PEER_CONTEXT_NOT_CONVERGED";
34
35// ── registry / network ──────────────────────────────────────────────
36pub const ERR_AUBE_PACKAGE_NOT_FOUND: &str = "ERR_AUBE_PACKAGE_NOT_FOUND";
37pub const ERR_AUBE_VERSION_NOT_FOUND: &str = "ERR_AUBE_VERSION_NOT_FOUND";
38pub const ERR_AUBE_UNAUTHORIZED: &str = "ERR_AUBE_UNAUTHORIZED";
39pub const ERR_AUBE_OFFLINE: &str = "ERR_AUBE_OFFLINE";
40pub const ERR_AUBE_INVALID_PACKAGE_NAME: &str = "ERR_AUBE_INVALID_PACKAGE_NAME";
41pub const ERR_AUBE_REGISTRY_WRITE_REJECTED: &str = "ERR_AUBE_REGISTRY_WRITE_REJECTED";
42
43// ── tarball / store ─────────────────────────────────────────────────
44pub const ERR_AUBE_TARBALL_INTEGRITY: &str = "ERR_AUBE_TARBALL_INTEGRITY";
45pub const ERR_AUBE_TARBALL_EXTRACT: &str = "ERR_AUBE_TARBALL_EXTRACT";
46pub const ERR_AUBE_PKG_CONTENT_MISMATCH: &str = "ERR_AUBE_PKG_CONTENT_MISMATCH";
47pub const ERR_AUBE_NO_HOME: &str = "ERR_AUBE_NO_HOME";
48pub const ERR_AUBE_GIT_ERROR: &str = "ERR_AUBE_GIT_ERROR";
49
50// ── linker ──────────────────────────────────────────────────────────
51pub const ERR_AUBE_LINK_FAILED: &str = "ERR_AUBE_LINK_FAILED";
52pub const ERR_AUBE_PATCH_FAILED: &str = "ERR_AUBE_PATCH_FAILED";
53pub const ERR_AUBE_MISSING_PACKAGE_INDEX: &str = "ERR_AUBE_MISSING_PACKAGE_INDEX";
54pub const ERR_AUBE_UNSAFE_INDEX_KEY: &str = "ERR_AUBE_UNSAFE_INDEX_KEY";
55pub const ERR_AUBE_MISSING_STORE_FILE: &str = "ERR_AUBE_MISSING_STORE_FILE";
56
57// ── scripts ─────────────────────────────────────────────────────────
58pub const ERR_AUBE_SCRIPT_SPAWN: &str = "ERR_AUBE_SCRIPT_SPAWN";
59pub const ERR_AUBE_SCRIPT_NON_ZERO_EXIT: &str = "ERR_AUBE_SCRIPT_NON_ZERO_EXIT";
60#[rustfmt::skip] pub const ERR_AUBE_BUILD_POLICY_UNSUPPORTED_VALUE: &str = "ERR_AUBE_BUILD_POLICY_UNSUPPORTED_VALUE";
61#[rustfmt::skip] pub const ERR_AUBE_BUILD_POLICY_INVALID_VERSION_UNION: &str = "ERR_AUBE_BUILD_POLICY_INVALID_VERSION_UNION";
62#[rustfmt::skip] pub const ERR_AUBE_BUILD_POLICY_WILDCARD_WITH_VERSION: &str = "ERR_AUBE_BUILD_POLICY_WILDCARD_WITH_VERSION";
63
64// ── workspace / filter ──────────────────────────────────────────────
65pub const ERR_AUBE_WORKSPACE_PARSE: &str = "ERR_AUBE_WORKSPACE_PARSE";
66pub const ERR_AUBE_FILTER_EMPTY: &str = "ERR_AUBE_FILTER_EMPTY";
67pub const ERR_AUBE_FILTER_GIT_IO: &str = "ERR_AUBE_FILTER_GIT_IO";
68pub const ERR_AUBE_FILTER_GIT_FAILED: &str = "ERR_AUBE_FILTER_GIT_FAILED";
69
70// ── manifest ────────────────────────────────────────────────────────
71pub const ERR_AUBE_MANIFEST_PARSE: &str = "ERR_AUBE_MANIFEST_PARSE";
72pub const ERR_AUBE_MANIFEST_YAML_PARSE: &str = "ERR_AUBE_MANIFEST_YAML_PARSE";
73
74// ── engine / cli ────────────────────────────────────────────────────
75pub const ERR_AUBE_UNSUPPORTED_ENGINE: &str = "ERR_AUBE_UNSUPPORTED_ENGINE";
76pub const ERR_AUBE_RECURSIVE_NOT_SUPPORTED: &str = "ERR_AUBE_RECURSIVE_NOT_SUPPORTED";
77pub const ERR_AUBE_UNKNOWN_COMMAND: &str = "ERR_AUBE_UNKNOWN_COMMAND";
78pub const ERR_AUBE_NPM_ONLY_COMMAND: &str = "ERR_AUBE_NPM_ONLY_COMMAND";
79pub const ERR_AUBE_COMPLETION_FAILED: &str = "ERR_AUBE_COMPLETION_FAILED";
80pub const ERR_AUBE_REMOVE_PRIOR_INSTALL_DIR: &str = "ERR_AUBE_REMOVE_PRIOR_INSTALL_DIR";
81
82// ── misc tracing::error! sites (non-fatal but high-severity) ────────
83pub const ERR_AUBE_PATCHES_TRACKING_WRITE: &str = "ERR_AUBE_PATCHES_TRACKING_WRITE";
84pub const ERR_AUBE_UNSAFE_SHEBANG_INTERPRETER: &str = "ERR_AUBE_UNSAFE_SHEBANG_INTERPRETER";
85
86/// Stable category labels that group codes in the generated docs and
87/// in `EXIT_TABLE`'s 10-wide allocation ranges. Public so the docs
88/// generator can iterate them in a deterministic order.
89pub mod category {
90    pub const LOCKFILE: &str = "Lockfile";
91    pub const RESOLVER: &str = "Resolver";
92    pub const TARBALL_STORE: &str = "Tarball / store";
93    pub const REGISTRY_NETWORK: &str = "Registry / network";
94    pub const SCRIPTS: &str = "Scripts / build";
95    pub const LINKER: &str = "Linker";
96    pub const MANIFEST_WORKSPACE: &str = "Manifest / workspace";
97    pub const ENGINE_CLI: &str = "Engine / CLI";
98    pub const MISC_SAFETY: &str = "Misc / safety";
99}
100
101/// Registry of every error code with its category, description, and
102/// (optional) bespoke exit code. Walked by the
103/// `generate-error-codes-docs` binary and by the self-tests in
104/// `lib.rs` and `exit.rs`. New codes must be added here.
105pub const ALL: &[CodeMeta] = &[
106    // Lockfile
107    CodeMeta {
108        name: ERR_AUBE_NO_LOCKFILE,
109        category: category::LOCKFILE,
110        description: "An operation that required a lockfile (`--frozen-lockfile`, `aube fetch`, etc.) found none in the project.",
111        exit_code: Some(10),
112    },
113    CodeMeta {
114        name: ERR_AUBE_LOCKFILE_PARSE,
115        category: category::LOCKFILE,
116        description: "Lockfile is structurally invalid — version guard failed, YAML shape is wrong, or `yaml_serde` couldn't round-trip the contents.",
117        exit_code: Some(11),
118    },
119    CodeMeta {
120        name: ERR_AUBE_LOCKFILE_UNSUPPORTED_FORMAT,
121        category: category::LOCKFILE,
122        description: "Lockfile filename was recognized but its format isn't supported on this aube version.",
123        exit_code: Some(12),
124    },
125    // Resolver
126    CodeMeta {
127        name: ERR_AUBE_NO_MATCHING_VERSION,
128        category: category::RESOLVER,
129        description: "No published version of the named package satisfies the requested range.",
130        exit_code: Some(20),
131    },
132    CodeMeta {
133        name: ERR_AUBE_NO_MATURE_MATCHING_VERSION,
134        category: category::RESOLVER,
135        description: "A version satisfying the range exists but every candidate was younger than `minimumReleaseAge` and `minimumReleaseAgeStrict=true`.",
136        exit_code: Some(21),
137    },
138    CodeMeta {
139        name: ERR_AUBE_BLOCKED_EXOTIC_SUBDEP,
140        category: category::RESOLVER,
141        description: "Transitive dep used a `git:` / `file:` / `tarball` specifier and `blockExoticSubdeps=true`.",
142        exit_code: Some(22),
143    },
144    CodeMeta {
145        name: ERR_AUBE_TRUST_DOWNGRADE,
146        category: category::RESOLVER,
147        description: "Picked version dropped trust evidence the prior version had (`trustPolicy=no-downgrade`).",
148        exit_code: Some(23),
149    },
150    CodeMeta {
151        name: ERR_AUBE_TRUST_MISSING_TIME,
152        category: category::RESOLVER,
153        description: "Registry's packument has no `time` entry for the picked version (`trustPolicy=no-downgrade`).",
154        exit_code: Some(24),
155    },
156    CodeMeta {
157        name: ERR_AUBE_UNKNOWN_CATALOG,
158        category: category::RESOLVER,
159        description: "A `catalog:<name>` reference was used but the catalog isn't defined.",
160        exit_code: Some(25),
161    },
162    CodeMeta {
163        name: ERR_AUBE_UNKNOWN_CATALOG_ENTRY,
164        category: category::RESOLVER,
165        description: "The catalog exists but has no entry for the requested package.",
166        exit_code: Some(26),
167    },
168    CodeMeta {
169        name: ERR_AUBE_PEER_CONTEXT_NOT_CONVERGED,
170        category: category::RESOLVER,
171        description: "Peer-context fixed-point loop hit `MAX_ITERATIONS=16` without converging — usually mutually-recursive peers.",
172        exit_code: Some(27),
173    },
174    CodeMeta {
175        name: ERR_AUBE_REGISTRY_ERROR,
176        category: category::RESOLVER,
177        description: "Generic registry error from inside the resolver.",
178        exit_code: None,
179    },
180    CodeMeta {
181        name: ERR_AUBE_TRUST_EXCLUDE_INVALID_VERSION_UNION,
182        category: category::RESOLVER,
183        description: "A `trustPolicyExclude` pattern had a non-exact version.",
184        exit_code: None,
185    },
186    CodeMeta {
187        name: ERR_AUBE_TRUST_EXCLUDE_NAME_GLOB_WITH_VERSIONS,
188        category: category::RESOLVER,
189        description: "A `trustPolicyExclude` pattern combined a name glob with versions.",
190        exit_code: None,
191    },
192    // Tarball / store
193    CodeMeta {
194        name: ERR_AUBE_TARBALL_INTEGRITY,
195        category: category::TARBALL_STORE,
196        description: "Downloaded tarball's hash didn't match the lockfile's / packument's `dist.integrity`.",
197        exit_code: Some(30),
198    },
199    CodeMeta {
200        name: ERR_AUBE_TARBALL_EXTRACT,
201        category: category::TARBALL_STORE,
202        description: "Tarball couldn't be extracted (corrupt gzip, unexpected entry shape, etc.).",
203        exit_code: Some(31),
204    },
205    CodeMeta {
206        name: ERR_AUBE_PKG_CONTENT_MISMATCH,
207        category: category::TARBALL_STORE,
208        description: "Tarball's `package.json` declared a different `(name, version)` than the resolver expected (`strictStorePkgContentCheck=true`).",
209        exit_code: Some(32),
210    },
211    CodeMeta {
212        name: ERR_AUBE_GIT_ERROR,
213        category: category::TARBALL_STORE,
214        description: "Git operation failed during a `git:` dep prepare or checkout.",
215        exit_code: Some(33),
216    },
217    CodeMeta {
218        name: ERR_AUBE_NO_HOME,
219        category: category::TARBALL_STORE,
220        description: "`HOME` (or platform equivalent) is unset, so aube can't locate its store.",
221        exit_code: None,
222    },
223    // Registry / network
224    CodeMeta {
225        name: ERR_AUBE_PACKAGE_NOT_FOUND,
226        category: category::REGISTRY_NETWORK,
227        description: "Registry returned 404 for the package name.",
228        exit_code: Some(40),
229    },
230    CodeMeta {
231        name: ERR_AUBE_VERSION_NOT_FOUND,
232        category: category::REGISTRY_NETWORK,
233        description: "Package exists but the requested version doesn't.",
234        exit_code: Some(41),
235    },
236    CodeMeta {
237        name: ERR_AUBE_UNAUTHORIZED,
238        category: category::REGISTRY_NETWORK,
239        description: "Registry returned 401/403 — missing or invalid auth. Run `aube login`.",
240        exit_code: Some(42),
241    },
242    CodeMeta {
243        name: ERR_AUBE_OFFLINE,
244        category: category::REGISTRY_NETWORK,
245        description: "Offline mode and the requested resource isn't in the local cache.",
246        exit_code: Some(43),
247    },
248    CodeMeta {
249        name: ERR_AUBE_INVALID_PACKAGE_NAME,
250        category: category::REGISTRY_NETWORK,
251        description: "A name doesn't match npm's grammar — rejected before any I/O so a hostile manifest can't use the cache-path builder as a write primitive.",
252        exit_code: Some(44),
253    },
254    CodeMeta {
255        name: ERR_AUBE_REGISTRY_WRITE_REJECTED,
256        category: category::REGISTRY_NETWORK,
257        description: "Registry rejected a publish/deprecate/owner write with a non-2xx response.",
258        exit_code: Some(45),
259    },
260    // Scripts / build
261    CodeMeta {
262        name: ERR_AUBE_SCRIPT_NON_ZERO_EXIT,
263        category: category::SCRIPTS,
264        description: "A lifecycle script (`preinstall` / `install` / `postinstall` / a `package.json` script) exited non-zero.",
265        exit_code: Some(50),
266    },
267    CodeMeta {
268        name: ERR_AUBE_SCRIPT_SPAWN,
269        category: category::SCRIPTS,
270        description: "Couldn't spawn a script's interpreter (shell missing, jail setup failed, etc.).",
271        exit_code: Some(51),
272    },
273    CodeMeta {
274        name: ERR_AUBE_BUILD_POLICY_UNSUPPORTED_VALUE,
275        category: category::SCRIPTS,
276        description: "An entry in `allowBuilds` had a value that wasn't `true`/`false`.",
277        exit_code: None,
278    },
279    CodeMeta {
280        name: ERR_AUBE_BUILD_POLICY_INVALID_VERSION_UNION,
281        category: category::SCRIPTS,
282        description: "An `allowBuilds` pattern's version union was unparseable.",
283        exit_code: None,
284    },
285    CodeMeta {
286        name: ERR_AUBE_BUILD_POLICY_WILDCARD_WITH_VERSION,
287        category: category::SCRIPTS,
288        description: "An `allowBuilds` pattern combined a wildcard name with a version union.",
289        exit_code: None,
290    },
291    // Linker
292    CodeMeta {
293        name: ERR_AUBE_PATCH_FAILED,
294        category: category::LINKER,
295        description: "Applying a `pnpm.patchedDependencies` patch failed.",
296        exit_code: Some(60),
297    },
298    CodeMeta {
299        name: ERR_AUBE_LINK_FAILED,
300        category: category::LINKER,
301        description: "Symlink / junction / hardlink couldn't be created — usually permissions or filesystem support.",
302        exit_code: Some(61),
303    },
304    CodeMeta {
305        name: ERR_AUBE_MISSING_PACKAGE_INDEX,
306        category: category::LINKER,
307        description: "Internal: a caller skipped `load_index` but the package wasn't already materialized.",
308        exit_code: Some(62),
309    },
310    CodeMeta {
311        name: ERR_AUBE_MISSING_STORE_FILE,
312        category: category::LINKER,
313        description: "A package index references a CAS shard that doesn't exist on disk. Re-run install to re-fetch.",
314        exit_code: Some(63),
315    },
316    // Manifest / workspace
317    CodeMeta {
318        name: ERR_AUBE_MANIFEST_PARSE,
319        category: category::MANIFEST_WORKSPACE,
320        description: "A `package.json` had a syntax error. miette renders a pointer at the offending byte.",
321        exit_code: Some(70),
322    },
323    CodeMeta {
324        name: ERR_AUBE_WORKSPACE_PARSE,
325        category: category::MANIFEST_WORKSPACE,
326        description: "An `aube-workspace.yaml` / `pnpm-workspace.yaml` was structurally invalid.",
327        exit_code: Some(71),
328    },
329    CodeMeta {
330        name: ERR_AUBE_MANIFEST_YAML_PARSE,
331        category: category::MANIFEST_WORKSPACE,
332        description: "A workspace YAML helper file was structurally invalid (no source pointer available).",
333        exit_code: None,
334    },
335    CodeMeta {
336        name: ERR_AUBE_FILTER_EMPTY,
337        category: category::MANIFEST_WORKSPACE,
338        description: "`--filter` was passed an empty selector.",
339        exit_code: None,
340    },
341    CodeMeta {
342        name: ERR_AUBE_FILTER_GIT_IO,
343        category: category::MANIFEST_WORKSPACE,
344        description: "A `--filter ...[ref]` selector failed to spawn `git`.",
345        exit_code: None,
346    },
347    CodeMeta {
348        name: ERR_AUBE_FILTER_GIT_FAILED,
349        category: category::MANIFEST_WORKSPACE,
350        description: "The git subprocess for a `--filter ...[ref]` selector exited non-zero.",
351        exit_code: None,
352    },
353    // Engine / CLI
354    CodeMeta {
355        name: ERR_AUBE_UNSUPPORTED_ENGINE,
356        category: category::ENGINE_CLI,
357        description: "One or more packages declared an `engines` constraint incompatible with the running Node/aube and `engine-strict=true`.",
358        exit_code: Some(80),
359    },
360    CodeMeta {
361        name: ERR_AUBE_UNKNOWN_COMMAND,
362        category: category::ENGINE_CLI,
363        description: "The named subcommand isn't a built-in aube command and isn't a script in the manifest.",
364        exit_code: Some(81),
365    },
366    CodeMeta {
367        name: ERR_AUBE_NPM_ONLY_COMMAND,
368        category: category::ENGINE_CLI,
369        description: "The user invoked an npm-only command (`whoami`, `token`, `owner`, `search`, `pkg`, `set-script`) — aube doesn't implement these; use npm.",
370        exit_code: Some(82),
371    },
372    CodeMeta {
373        name: ERR_AUBE_RECURSIVE_NOT_SUPPORTED,
374        category: category::ENGINE_CLI,
375        description: "A command was invoked under `--recursive` but doesn't support recursive execution.",
376        exit_code: None,
377    },
378    CodeMeta {
379        name: ERR_AUBE_COMPLETION_FAILED,
380        category: category::ENGINE_CLI,
381        description: "`aube completion` couldn't invoke `usage` to render the shell completions.",
382        exit_code: None,
383    },
384    CodeMeta {
385        name: ERR_AUBE_REMOVE_PRIOR_INSTALL_DIR,
386        category: category::ENGINE_CLI,
387        description: "Couldn't clean up a prior global install dir before re-installing.",
388        exit_code: None,
389    },
390    // Misc / safety
391    CodeMeta {
392        name: ERR_AUBE_UNSAFE_INDEX_KEY,
393        category: category::MISC_SAFETY,
394        description: "A package index key tried to escape its directory (path traversal defense in depth).",
395        exit_code: Some(90),
396    },
397    CodeMeta {
398        name: ERR_AUBE_UNSAFE_SHEBANG_INTERPRETER,
399        category: category::MISC_SAFETY,
400        description: "A `#!` shebang named an unsafe interpreter when generating a shim — substituted with `node` instead. Surfaced as `tracing::error!` but install continues.",
401        exit_code: Some(91),
402    },
403    CodeMeta {
404        name: ERR_AUBE_PATCHES_TRACKING_WRITE,
405        category: category::MISC_SAFETY,
406        description: "Couldn't write `.aube-applied-patches.json` after applying patches. Non-fatal; next install may miss stale patched entries.",
407        exit_code: None,
408    },
409];