Skip to content

Errors

Troubleshooting

SymptomCheck first
No attachment tablesRun node ace make:attachments-table, then node ace migration:run; check integrations.lucid.tableName for custom names.
createFromFile fails before persistenceCheck that the upload exists, is valid, and has a temporary path. See the validated upload example.
Original exists but thumbnail is absentConfirm the key is enabled in variants, check the required media dependency, and report queue failures with onFailure. External queues also need a running worker.
Invalid attachment queue default at bootCheck that queue.default matches a key in queue.connections. Validate ATTACHMENT_QUEUE with an enum when selecting by environment; no fallback is applied to an unknown name.
File route returns 404Use the blob ID, not the link ID. Check the route prefix and repository; without Lucid or an explicit repository, no route is registered.
Private file is still publicly accessibleSet route: false and check that the underlying storage does not also expose a public URL.
Filename rejected by DriveKeep normalizeFileName: true, especially with rename: false; see folder and rename.

Catching errors

Every error emitted by the package extends AttachmentError, itself an Adonis Exception. It exposes a stable code, a HTTP-oriented status, and an optional cause. Catch the base class when an application needs one handling path for storage, sources, queues, or Lucid.

ts
import { AttachmentError } from '@jrmc/adonis-attachment'

try {
  await attachmentManager.createFromBase64(input)
} catch (error) {
  if (error instanceof AttachmentError) {
    logger.warn({ code: error.code, status: error.status, cause: error.cause }, error.message)
    throw error
  }

  throw error
}

Public errors

ErrorCodeStatusMeaning
AttachmentSourceErrorE_ATTACHMENT_SOURCE400A source cannot be normalized. Specific source failures use the codes below.
AttachmentNotFoundErrorE_ATTACHMENT_NOT_FOUND404A worker cannot load its original attachment.
UnknownVariantConverterErrorE_UNKNOWN_VARIANT_CONVERTER422A requested variant key has no converter.
InvalidConverterModuleErrorE_INVALID_CONVERTER_MODULE500A configured converter module has an unsupported export.
DeferredMetadataNotConfiguredErrorE_METADATA_NOT_CONFIGURED500Deferred metadata has no extractors or persister.
DeferredMetadataProcessorNotConfiguredErrorE_METADATA_PROCESSOR_NOT_CONFIGURED500A worker has no metadata processor.
AttachmentProcessorNotConfiguredErrorE_ATTACHMENT_PROCESSOR_NOT_CONFIGURED500The memory queue has no processor and Lucid is unavailable.
PersistedAttachmentNotFoundErrorE_PERSISTED_ATTACHMENT_NOT_FOUND404A variant job targets a blob that no longer exists.
CommandExecutionErrorE_COMMAND_EXECUTION_FAILED500An external binary exits unsuccessfully.
CommandTimeoutErrorE_COMMAND_TIMEOUT504An external binary exceeds its configured timeout.
MissingOptionalDependencyErrorE_MISSING_PACKAGE500An enabled optional adapter cannot load its dependency.

CommandExecutionError and CommandTimeoutError are exported by @jrmc/adonis-attachment/media/binaries; the other errors in this table are exported from the package root.

Other stable codes

Input and source errors include E_ISNOT_BASE64, E_ATTACHMENT_SOURCE_TOO_LARGE (413), E_MULTIPART_SOURCE_PATH_MISSING, and E_ATTACHMENT_SOURCE_DOWNLOAD_FAILED (502). Configuration and integration failures use E_INVALID_ATTACHMENT_CONFIG, E_INVALID_ATTACHMENT_ROUTE, E_INVALID_ATTACHMENT_TABLE_NAME, E_DRIVE_CONFIG_NOT_FOUND, and E_ATTACHMENT_CONFIGURATION.

Attachment invariants use E_ATTACHMENT_DRAFT_SOURCE_UNAVAILABLE, E_ATTACHMENT_DRAFT_NOT_PERSISTED, E_INVALID_ATTACHMENT_NAME, and E_INVALID_ATTACHMENT_FOLDER. Collection and relation validation uses E_INVALID_ATTACHMENT or E_ATTACHMENT_CONFLICT (409).

Optional processing

Blurhash generation is intentionally best-effort: when its optional dependencies are missing or encoding fails, the generated variant is retained without a blurhash. No exception reaches the caller in that case. Other optional adapters, such as EXIF and Sharp autodetection, throw MissingOptionalDependencyError when invoked without their dependency.