From 78caa079173800f0bfe7dd7834b44bc8b1b74bbc Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Sat, 19 Sep 2026 05:36:10 +0000 Subject: [PATCH] chore(errors): drop the dead STORAGE_* file-processing lifecycle codes Re-audited constructive-db main (post #3834): the seven SQL-side lifecycle codes are raised nowhere, and the two runtime-only companions have no caller in any repo. Regenerated the inventory/registry and removed the curated entries plus the test that pinned them. --- .../__tests__/storage-lifecycle.test.ts | 428 ------------------ .../errors/scripts/db-error-inventory.json | 56 --- .../src/generated/registry.generated.ts | 20 +- packages/errors/src/registry.ts | 84 ---- 4 files changed, 3 insertions(+), 585 deletions(-) delete mode 100644 packages/errors/__tests__/storage-lifecycle.test.ts diff --git a/packages/errors/__tests__/storage-lifecycle.test.ts b/packages/errors/__tests__/storage-lifecycle.test.ts deleted file mode 100644 index 174ba73a2..000000000 --- a/packages/errors/__tests__/storage-lifecycle.test.ts +++ /dev/null @@ -1,428 +0,0 @@ -import { readFileSync } from 'fs'; -import { join } from 'path'; - -import { - allCodes, - classify, - errors, - format, - getDefinition, - httpStatusFor, - parse, - toError, -} from '../src'; -import { - GENERATED_CODE_META, - generatedRegistry, -} from '../src/generated/registry.generated'; - -const inventory: Record = JSON.parse( - readFileSync(join(__dirname, '../scripts/db-error-inventory.json'), 'utf-8') -); - -const SQL_CODES = [ - 'STORAGE_ACCESS_CLAIM_MISMATCH', - 'STORAGE_FILE_NOT_FOUND', - 'STORAGE_SOURCE_HASH_REQUIRED', - 'STORAGE_SOURCE_HASH_MISMATCH', - 'STORAGE_INVALID_COMPLETION_RESULT', - 'STORAGE_PROCESSING_CONFLICT', - 'STORAGE_INVALID_UPLOAD_DOCUMENT', -] as const; - -const RUNTIME_ONLY_CODES = [ - 'STORAGE_BUCKET_DATABASE_MISMATCH', - 'STORAGE_FILE_TARGET_UNAVAILABLE', -] as const; - -type SqlContext = { - database_id: string | null; - file_id: string | null; - bucket_id: string | null; -}; - -const lifecycleDefinitions = [ - { - code: 'STORAGE_ACCESS_CLAIM_MISMATCH', - class: 'public', - http: 403, - message: 'You do not have permission to process this file.', - }, - { - code: 'STORAGE_FILE_NOT_FOUND', - class: 'public', - http: 404, - message: 'The file could not be found.', - }, - { - code: 'STORAGE_SOURCE_HASH_REQUIRED', - class: 'public', - http: 400, - message: 'A valid source file hash is required.', - }, - { - code: 'STORAGE_SOURCE_HASH_MISMATCH', - class: 'public', - http: 409, - message: 'The source file has changed. Please process it again.', - }, - { - code: 'STORAGE_INVALID_COMPLETION_RESULT', - class: 'public', - http: 400, - message: 'The file processing result is invalid.', - }, - { - code: 'STORAGE_PROCESSING_CONFLICT', - class: 'public', - http: 409, - message: 'The file is not in a state that allows this processing result.', - }, - { - code: 'STORAGE_INVALID_UPLOAD_DOCUMENT', - class: 'internal', - http: 500, - message: 'The stored upload document is invalid.', - }, - { - code: 'STORAGE_BUCKET_DATABASE_MISMATCH', - class: 'internal', - http: 500, - message: 'The storage bucket does not belong to the invocation database.', - }, - { - code: 'STORAGE_FILE_TARGET_UNAVAILABLE', - class: 'internal', - http: 500, - message: 'The storage file target is unavailable.', - }, -] as const; - -const publicStorageContext = { - database_id: 'db-1', - file_id: 'file-1', - bucket_id: 'bucket-1', -}; - -describe('storage lifecycle registry entries', () => { - it('exposes every lifecycle code with its public contract and stable copy', () => { - for (const expected of lifecycleDefinitions) { - const definition = getDefinition(expected.code); - - expect(definition).toMatchObject(expected); - expect(classify(expected.code)).toBe(expected.class); - expect(httpStatusFor(expected.code)).toEqual({ - status: expected.http, - mapped: true, - }); - expect(format(expected.code)).toBe(expected.message); - expect(format(expected.code, publicStorageContext)).toBe( - expected.message - ); - expect(allCodes()).toContain(expected.code); - } - }); - - it('keeps SQL and runtime provenance synchronized', () => { - for (const code of SQL_CODES) { - expect(inventory[code]).toBeDefined(); - expect(generatedRegistry[code]).toBeDefined(); - expect(GENERATED_CODE_META[code]).toBeDefined(); - } - for (const code of RUNTIME_ONLY_CODES) { - expect(inventory[code]).toBeUndefined(); - expect(generatedRegistry[code]).toBeUndefined(); - expect(GENERATED_CODE_META[code]).toBeUndefined(); - } - }); -}); - -describe('storage lifecycle PostgreSQL DETAIL transport', () => { - const sqlContext: SqlContext = { - database_id: 'db-1', - file_id: 'file-1', - bucket_id: 'bucket-1', - }; - const sqlDetails = SQL_CODES.map((code) => ({ - code, - class: code === 'STORAGE_INVALID_UPLOAD_DOCUMENT' ? 'internal' : 'public', - context: sqlContext, - })); - - // NULL values come directly from the SQL helper's nullable claims/arguments. - sqlDetails[0].context = { - database_id: null, - file_id: 'file-1', - bucket_id: 'bucket-1', - }; - sqlDetails[1].context = { - database_id: 'db-1', - file_id: null, - bucket_id: 'bucket-1', - }; - - it('recovers known code, explicit class, raw message, and nullable SQL context', () => { - for (const detail of sqlDetails) { - const parsed = parse({ - message: detail.code, - code: 'P0001', - detail: JSON.stringify({ - code: detail.code, - context: detail.context, - class: detail.class, - }), - }); - - expect(parsed).toMatchObject({ - code: detail.code, - context: detail.context, - class: detail.class, - known: true, - rawMessage: detail.code, - sqlState: 'P0001', - }); - expect(parsed.context).toEqual(detail.context); - } - }); - - it('falls back to the registry when DETAIL omits class', () => { - for (const expected of lifecycleDefinitions) { - const parsed = parse({ - message: expected.code, - code: 'P0001', - detail: JSON.stringify({ code: expected.code, context: {} }), - }); - - expect(parsed.class).toBe(expected.class); - expect(parsed.known).toBe(true); - } - }); - - it('trusts an explicit class even when it differs from the registry', () => { - for (const expected of lifecycleDefinitions) { - const explicitClass = expected.class === 'public' ? 'internal' : 'public'; - const parsed = parse({ - message: expected.code, - code: 'P0001', - detail: JSON.stringify({ - code: expected.code, - context: {}, - class: explicitClass, - }), - }); - - expect(parsed.class).toBe(explicitClass); - expect(parsed.known).toBe(true); - } - }); - - it('normalizes every raw lifecycle transport with registry copy and status', () => { - const contexts = { - STORAGE_ACCESS_CLAIM_MISMATCH: publicStorageContext, - STORAGE_FILE_NOT_FOUND: publicStorageContext, - STORAGE_SOURCE_HASH_REQUIRED: publicStorageContext, - STORAGE_SOURCE_HASH_MISMATCH: publicStorageContext, - STORAGE_INVALID_COMPLETION_RESULT: publicStorageContext, - STORAGE_PROCESSING_CONFLICT: publicStorageContext, - STORAGE_INVALID_UPLOAD_DOCUMENT: publicStorageContext, - STORAGE_BUCKET_DATABASE_MISMATCH: { - bucket: 'exports', - bucketDatabaseId: 'db-bucket', - invocationDatabaseId: 'db-invocation', - }, - STORAGE_FILE_TARGET_UNAVAILABLE: { - bucket: 'exports', - bucketId: 'bucket-1', - }, - } as const; - - for (const expected of lifecycleDefinitions) { - const err = toError({ - message: expected.code, - code: 'P0001', - detail: JSON.stringify({ - code: expected.code, - context: contexts[expected.code], - }), - }); - - expect(err).toMatchObject({ - code: expected.code, - errorClass: expected.class, - http: expected.http, - message: expected.message, - context: contexts[expected.code], - }); - expect(err.context).toEqual(contexts[expected.code]); - } - }); - - it('uses the registry HTTP status even when DB class is explicitly internal', () => { - for (const expected of lifecycleDefinitions.filter( - (item) => item.class === 'public' - )) { - const err = toError({ - message: expected.code, - code: 'P0001', - detail: JSON.stringify({ - code: expected.code, - context: publicStorageContext, - class: 'internal', - }), - }); - - expect(err.errorClass).toBe('internal'); - expect(err.http).toBe(expected.http); - expect(httpStatusFor(expected.code)).toEqual({ - status: expected.http, - mapped: true, - }); - } - }); - - it('parses runtime DETAIL with camelCase validation context', () => { - const context = { - field: 'output', - reason: 'serialized_size', - maxBytes: 64 * 1024, - }; - const parsed = parse({ - message: 'STORAGE_INVALID_COMPLETION_RESULT', - code: 'STORAGE_INVALID_COMPLETION_RESULT', - detail: JSON.stringify({ - code: 'STORAGE_INVALID_COMPLETION_RESULT', - context, - class: 'internal', - }), - }); - - expect(parsed).toMatchObject({ - code: 'STORAGE_INVALID_COMPLETION_RESULT', - context, - class: 'internal', - known: true, - rawMessage: 'STORAGE_INVALID_COMPLETION_RESULT', - }); - expect(parsed.context).toEqual(context); - }); -}); - -describe('storage lifecycle runtime contexts', () => { - it('builds both runtime-only context variants as known internal errors', () => { - const cases = [ - { - code: 'STORAGE_BUCKET_DATABASE_MISMATCH' as const, - contexts: [ - { - bucket: 'exports', - capabilitiesDatabaseId: 'db-capabilities', - invocationDatabaseId: null as string | null, - reason: 'capability_bundle_database_mismatch', - }, - { - bucket: 'exports', - bucketDatabaseId: 'db-bucket', - invocationDatabaseId: 'db-invocation', - }, - ], - }, - { - code: 'STORAGE_FILE_TARGET_UNAVAILABLE' as const, - contexts: [ - { bucket: 'exports', reason: 'database_unavailable' }, - { bucket: 'exports', bucketId: 'bucket-1' }, - ], - }, - ]; - - for (const entry of cases) { - for (const context of entry.contexts) { - const err = errors[entry.code](context); - expect(err).toMatchObject({ - code: entry.code, - errorClass: 'internal', - http: 500, - context, - }); - expect(err.context).toEqual(context); - expect(parse(err)).toMatchObject({ - code: entry.code, - context, - class: 'internal', - known: true, - }); - expect(parse(err).context).toEqual(context); - } - } - }); - - it('accepts SQL and runtime context variants for shared codes', () => { - const fileNotFound = errors.STORAGE_FILE_NOT_FOUND({ - database_id: null, - file_id: null, - bucket_id: null, - }); - const invalidTarget = errors.STORAGE_FILE_NOT_FOUND({ - reason: 'invalid_target', - }); - const resolvedTarget = errors.STORAGE_FILE_NOT_FOUND({ - bucket: 'exports', - fileId: 'file-1', - }); - const sourceHashRequired = errors.STORAGE_SOURCE_HASH_REQUIRED({ - database_id: 'db-1', - file_id: null, - bucket_id: null, - }); - const missingHash = errors.STORAGE_SOURCE_HASH_REQUIRED({ - field: 'expected.contentHash', - }); - const invalidResult = errors.STORAGE_INVALID_COMPLETION_RESULT({ - database_id: null, - file_id: 'file-1', - bucket_id: 'bucket-1', - }); - const serializationFailure = errors.STORAGE_INVALID_COMPLETION_RESULT({ - field: 'output', - reason: 'serialization_failed', - cause: 'Converting circular structure to JSON', - }); - const oversizedResult = errors.STORAGE_INVALID_COMPLETION_RESULT({ - field: 'output', - reason: 'serialized_size', - maxBytes: 64 * 1024, - }); - - expect(fileNotFound.context).toMatchObject({ - database_id: null, - file_id: null, - bucket_id: null, - }); - expect(invalidTarget.context).toEqual({ reason: 'invalid_target' }); - expect(resolvedTarget.context).toEqual({ - bucket: 'exports', - fileId: 'file-1', - }); - expect(sourceHashRequired.context).toMatchObject({ - database_id: 'db-1', - file_id: null, - bucket_id: null, - }); - expect(missingHash.context).toEqual({ field: 'expected.contentHash' }); - expect(invalidResult.context).toMatchObject({ - database_id: null, - file_id: 'file-1', - bucket_id: 'bucket-1', - }); - expect(serializationFailure.context).toMatchObject({ - field: 'output', - reason: 'serialization_failed', - cause: 'Converting circular structure to JSON', - }); - expect(oversizedResult.context).toMatchObject({ - field: 'output', - reason: 'serialized_size', - maxBytes: 64 * 1024, - }); - }); -}); diff --git a/packages/errors/scripts/db-error-inventory.json b/packages/errors/scripts/db-error-inventory.json index 306abe494..cc8a2ee76 100644 --- a/packages/errors/scripts/db-error-inventory.json +++ b/packages/errors/scripts/db-error-inventory.json @@ -5825,14 +5825,6 @@ "n_generated": 3, "class": "public" }, - "STORAGE_ACCESS_CLAIM_MISMATCH": { - "count": 18, - "dynamic": false, - "sample": "STORAGE_ACCESS_CLAIM_MISMATCH", - "n_source": 1, - "n_generated": 4, - "class": "public" - }, "STORAGE_API_NOT_PROVISIONED": { "count": 2, "dynamic": false, @@ -5865,14 +5857,6 @@ "n_generated": 4, "class": "internal" }, - "STORAGE_FILE_NOT_FOUND": { - "count": 6, - "dynamic": false, - "sample": "STORAGE_FILE_NOT_FOUND", - "n_source": 1, - "n_generated": 4, - "class": "public" - }, "STORAGE_GC_CONTENT_HASH_UNSUPPORTED": { "count": 2, "dynamic": false, @@ -5945,22 +5929,6 @@ "n_generated": 1, "class": "internal" }, - "STORAGE_INVALID_COMPLETION_RESULT": { - "count": 6, - "dynamic": false, - "sample": "STORAGE_INVALID_COMPLETION_RESULT", - "n_source": 1, - "n_generated": 4, - "class": "public" - }, - "STORAGE_INVALID_UPLOAD_DOCUMENT": { - "count": 6, - "dynamic": false, - "sample": "STORAGE_INVALID_UPLOAD_DOCUMENT", - "n_source": 1, - "n_generated": 4, - "class": "internal" - }, "STORAGE_MODULE_ENTITY_FIELD_INVALID": { "count": 2, "dynamic": false, @@ -5977,14 +5945,6 @@ "n_generated": 1, "class": "internal" }, - "STORAGE_PROCESSING_CONFLICT": { - "count": 6, - "dynamic": false, - "sample": "STORAGE_PROCESSING_CONFLICT", - "n_source": 1, - "n_generated": 4, - "class": "public" - }, "STORAGE_PROMOTION_DESTINATION_MISMATCH": { "count": 7, "dynamic": false, @@ -6001,22 +5961,6 @@ "n_generated": 4, "class": "internal" }, - "STORAGE_SOURCE_HASH_MISMATCH": { - "count": 6, - "dynamic": false, - "sample": "STORAGE_SOURCE_HASH_MISMATCH", - "n_source": 1, - "n_generated": 4, - "class": "public" - }, - "STORAGE_SOURCE_HASH_REQUIRED": { - "count": 12, - "dynamic": false, - "sample": "STORAGE_SOURCE_HASH_REQUIRED", - "n_source": 1, - "n_generated": 4, - "class": "public" - }, "STORAGE_STAGING_BUCKET_NO_DESTINATION": { "count": 7, "dynamic": false, diff --git a/packages/errors/src/generated/registry.generated.ts b/packages/errors/src/generated/registry.generated.ts index e4a482417..babfb0757 100644 --- a/packages/errors/src/generated/registry.generated.ts +++ b/packages/errors/src/generated/registry.generated.ts @@ -2,7 +2,7 @@ /** * GENERATED FILE — DO NOT EDIT BY HAND. * - * Source of truth: the constructive-db error audit (824 distinct codes + * Source of truth: the constructive-db error audit (817 distinct codes * raised via EXCEPTION/THROW across deploy sources + generated output). * Regenerate with `python3 scripts/generate-registry.py` (see README.md). * @@ -10,7 +10,7 @@ * codes carry their raw message (with %-args rendered as {{argN}}). Curated * entries in `registry.ts` override anything here (typed context + refined copy). * - * Counts: 824 total, 604 public, 220 internal. + * Counts: 817 total, 598 public, 219 internal. */ import { defineError, type DefinedError } from '../define'; import type { ErrorContext } from '../types'; @@ -763,12 +763,10 @@ export const generatedRegistry: Record> = { 'STEP_UP_REQUIRED_FRESH_AUTH': defineError({ code: 'STEP_UP_REQUIRED_FRESH_AUTH', class: 'public', http: 403, message: 'Please verify your identity to continue.' }), 'STEP_UP_REQUIRED_MFA': defineError({ code: 'STEP_UP_REQUIRED_MFA', class: 'public', http: 403, message: 'Please enter a code from your authenticator app to continue.' }), 'STEP_UP_REQUIRED_PASSWORD': defineError({ code: 'STEP_UP_REQUIRED_PASSWORD', class: 'public', http: 403, message: 'Please re-enter your password to continue.' }), - 'STORAGE_ACCESS_CLAIM_MISMATCH': defineError({ code: 'STORAGE_ACCESS_CLAIM_MISMATCH', class: 'public', http: 400, message: 'Storage access claim mismatch.' }), 'STORAGE_API_NOT_PROVISIONED': defineError({ code: 'STORAGE_API_NOT_PROVISIONED', class: 'public', http: 400, message: 'Storage api not provisioned.' }), 'STORAGE_DESTINATION_REQUIRES_TEMP': defineError({ code: 'STORAGE_DESTINATION_REQUIRES_TEMP', class: 'internal', http: 500, message: 'Storage destination requires temp.' }), 'STORAGE_FILE_BUCKET_IMMUTABLE': defineError({ code: 'STORAGE_FILE_BUCKET_IMMUTABLE', class: 'internal', http: 500, message: 'Storage file bucket immutable.' }), 'STORAGE_FILE_KEY_IMMUTABLE': defineError({ code: 'STORAGE_FILE_KEY_IMMUTABLE', class: 'internal', http: 500, message: 'Storage file key immutable.' }), - 'STORAGE_FILE_NOT_FOUND': defineError({ code: 'STORAGE_FILE_NOT_FOUND', class: 'public', http: 404, message: 'Storage file not found.' }), 'STORAGE_GC_CONTENT_HASH_UNSUPPORTED': defineError({ code: 'STORAGE_GC_CONTENT_HASH_UNSUPPORTED', class: 'internal', http: 500, message: 'Storage gc content hash unsupported.' }), 'STORAGE_GC_FILES_TABLE_MISSING': defineError({ code: 'STORAGE_GC_FILES_TABLE_MISSING', class: 'internal', http: 500, message: 'Storage gc files table missing.' }), 'STORAGE_GC_MODULE_AMBIGUOUS': defineError({ code: 'STORAGE_GC_MODULE_AMBIGUOUS', class: 'internal', http: 500, message: 'Storage gc module ambiguous.' }), @@ -778,15 +776,10 @@ export const generatedRegistry: Record> = { 'STORAGE_GC_REF_CROSS_DATABASE': defineError({ code: 'STORAGE_GC_REF_CROSS_DATABASE', class: 'internal', http: 500, message: 'Storage gc ref cross database.' }), 'STORAGE_GC_REF_FIELD_MISSING': defineError({ code: 'STORAGE_GC_REF_FIELD_MISSING', class: 'internal', http: 500, message: 'Storage gc ref field missing.' }), 'STORAGE_GC_REF_TABLE_MISSING': defineError({ code: 'STORAGE_GC_REF_TABLE_MISSING', class: 'internal', http: 500, message: 'Storage gc ref table missing.' }), - 'STORAGE_INVALID_COMPLETION_RESULT': defineError({ code: 'STORAGE_INVALID_COMPLETION_RESULT', class: 'public', http: 400, message: 'Storage invalid completion result.' }), - 'STORAGE_INVALID_UPLOAD_DOCUMENT': defineError({ code: 'STORAGE_INVALID_UPLOAD_DOCUMENT', class: 'internal', http: 500, message: 'Storage invalid upload document.' }), 'STORAGE_MODULE_ENTITY_FIELD_INVALID': defineError({ code: 'STORAGE_MODULE_ENTITY_FIELD_INVALID', class: 'internal', http: 500, message: 'Storage module entity field invalid.' }), 'STORAGE_MODULE_NOT_FOUND': defineError({ code: 'STORAGE_MODULE_NOT_FOUND', class: 'internal', http: 500, message: 'Storage module not found.' }), - 'STORAGE_PROCESSING_CONFLICT': defineError({ code: 'STORAGE_PROCESSING_CONFLICT', class: 'public', http: 400, message: 'Storage processing conflict.' }), 'STORAGE_PROMOTION_DESTINATION_MISMATCH': defineError({ code: 'STORAGE_PROMOTION_DESTINATION_MISMATCH', class: 'internal', http: 500, message: 'Storage promotion destination mismatch.' }), 'STORAGE_PROMOTION_VISIBILITY_MISMATCH': defineError({ code: 'STORAGE_PROMOTION_VISIBILITY_MISMATCH', class: 'internal', http: 500, message: 'Storage promotion visibility mismatch.' }), - 'STORAGE_SOURCE_HASH_MISMATCH': defineError({ code: 'STORAGE_SOURCE_HASH_MISMATCH', class: 'public', http: 400, message: 'Storage source hash mismatch.' }), - 'STORAGE_SOURCE_HASH_REQUIRED': defineError({ code: 'STORAGE_SOURCE_HASH_REQUIRED', class: 'public', http: 400, message: 'Storage source hash required.' }), 'STORAGE_STAGING_BUCKET_NO_DESTINATION': defineError({ code: 'STORAGE_STAGING_BUCKET_NO_DESTINATION', class: 'internal', http: 500, message: 'Storage staging bucket no destination.' }), 'STORAGE_STAGING_BUCKET_NO_TTL': defineError({ code: 'STORAGE_STAGING_BUCKET_NO_TTL', class: 'internal', http: 500, message: 'Storage staging bucket no ttl.' }), 'STORAGE_STAGING_DESTINATION_INVALID': defineError({ code: 'STORAGE_STAGING_DESTINATION_INVALID', class: 'internal', http: 500, message: 'Storage staging destination invalid.' }), @@ -1591,12 +1584,10 @@ export const GENERATED_CODE_META: Record = { 'STEP_UP_REQUIRED_FRESH_AUTH': { class: 'public', dynamic: false, generatedOnly: false }, 'STEP_UP_REQUIRED_MFA': { class: 'public', dynamic: false, generatedOnly: false }, 'STEP_UP_REQUIRED_PASSWORD': { class: 'public', dynamic: false, generatedOnly: false }, - 'STORAGE_ACCESS_CLAIM_MISMATCH': { class: 'public', dynamic: false, generatedOnly: false }, 'STORAGE_API_NOT_PROVISIONED': { class: 'public', dynamic: false, generatedOnly: false }, 'STORAGE_DESTINATION_REQUIRES_TEMP': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_FILE_BUCKET_IMMUTABLE': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_FILE_KEY_IMMUTABLE': { class: 'internal', dynamic: false, generatedOnly: false }, - 'STORAGE_FILE_NOT_FOUND': { class: 'public', dynamic: false, generatedOnly: false }, 'STORAGE_GC_CONTENT_HASH_UNSUPPORTED': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_GC_FILES_TABLE_MISSING': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_GC_MODULE_AMBIGUOUS': { class: 'internal', dynamic: false, generatedOnly: false }, @@ -1606,15 +1597,10 @@ export const GENERATED_CODE_META: Record = { 'STORAGE_GC_REF_CROSS_DATABASE': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_GC_REF_FIELD_MISSING': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_GC_REF_TABLE_MISSING': { class: 'internal', dynamic: false, generatedOnly: false }, - 'STORAGE_INVALID_COMPLETION_RESULT': { class: 'public', dynamic: false, generatedOnly: false }, - 'STORAGE_INVALID_UPLOAD_DOCUMENT': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_MODULE_ENTITY_FIELD_INVALID': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_MODULE_NOT_FOUND': { class: 'internal', dynamic: false, generatedOnly: false }, - 'STORAGE_PROCESSING_CONFLICT': { class: 'public', dynamic: false, generatedOnly: false }, 'STORAGE_PROMOTION_DESTINATION_MISMATCH': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_PROMOTION_VISIBILITY_MISMATCH': { class: 'internal', dynamic: false, generatedOnly: false }, - 'STORAGE_SOURCE_HASH_MISMATCH': { class: 'public', dynamic: false, generatedOnly: false }, - 'STORAGE_SOURCE_HASH_REQUIRED': { class: 'public', dynamic: false, generatedOnly: false }, 'STORAGE_STAGING_BUCKET_NO_DESTINATION': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_STAGING_BUCKET_NO_TTL': { class: 'internal', dynamic: false, generatedOnly: false }, 'STORAGE_STAGING_DESTINATION_INVALID': { class: 'internal', dynamic: false, generatedOnly: false }, @@ -1679,4 +1665,4 @@ export const GENERATED_CODE_META: Record = { }; /** Total number of codes collected from constructive-db. */ -export const GENERATED_CODE_COUNT = 824; +export const GENERATED_CODE_COUNT = 817; diff --git a/packages/errors/src/registry.ts b/packages/errors/src/registry.ts index 362dff60b..374e33c88 100644 --- a/packages/errors/src/registry.ts +++ b/packages/errors/src/registry.ts @@ -4,14 +4,6 @@ import type { ErrorContext, ErrorDefinition } from './types'; export { type DefinedError,defineError } from './define'; -// SQL completion errors carry these keys verbatim; NULL claims/arguments are -// possible. Runtime validation can fail before a database target is resolved. -type StorageFileContext = { - database_id?: string | null; - file_id?: string | null; - bucket_id?: string | null; -}; - /** * The curated Constructive error registry. * @@ -28,82 +20,6 @@ export const registry = { http: 409, message: 'The storage bucket has not yet been reconciled.' }), - // File processing lifecycle — curated HTTP hints override the generated - // name-based heuristic, particularly for access and processing conflicts. - STORAGE_ACCESS_CLAIM_MISMATCH: defineError({ - code: 'STORAGE_ACCESS_CLAIM_MISMATCH', - class: 'public', - http: 403, - message: 'You do not have permission to process this file.' - }), - STORAGE_FILE_NOT_FOUND: defineError({ - code: 'STORAGE_FILE_NOT_FOUND', - class: 'public', - http: 404, - message: 'The file could not be found.' - }), - STORAGE_SOURCE_HASH_REQUIRED: defineError({ - code: 'STORAGE_SOURCE_HASH_REQUIRED', - class: 'public', - http: 400, - message: 'A valid source file hash is required.' - }), - STORAGE_SOURCE_HASH_MISMATCH: defineError({ - code: 'STORAGE_SOURCE_HASH_MISMATCH', - class: 'public', - http: 409, - message: 'The source file has changed. Please process it again.' - }), - STORAGE_INVALID_COMPLETION_RESULT: defineError({ - code: 'STORAGE_INVALID_COMPLETION_RESULT', - class: 'public', - http: 400, - message: 'The file processing result is invalid.' - }), - STORAGE_PROCESSING_CONFLICT: defineError({ - code: 'STORAGE_PROCESSING_CONFLICT', - class: 'public', - http: 409, - message: 'The file is not in a state that allows this processing result.' - }), - STORAGE_INVALID_UPLOAD_DOCUMENT: defineError({ - code: 'STORAGE_INVALID_UPLOAD_DOCUMENT', - class: 'internal', - http: 500, - message: 'The stored upload document is invalid.' - }), - // Runtime-only dispatch errors; these have no database audit records. - STORAGE_BUCKET_DATABASE_MISMATCH: defineError<{ - bucket: string; - capabilitiesDatabaseId?: string; - bucketDatabaseId?: string; - invocationDatabaseId?: string | null; - reason?: string; - }>({ - code: 'STORAGE_BUCKET_DATABASE_MISMATCH', - class: 'internal', - http: 500, - message: 'The storage bucket does not belong to the invocation database.' - }), - STORAGE_FILE_TARGET_UNAVAILABLE: defineError<{ - bucket: string; - bucketId?: string; - reason?: string; - }>({ - code: 'STORAGE_FILE_TARGET_UNAVAILABLE', - class: 'internal', - http: 500, - message: 'The storage file target is unavailable.' - }), // =========================================================================== // Auth / account (public) — copy sourced from dashboard auth-errors.ts