Skip to content

Repository Service Errors

consortium.server.exceptions.service_exceptions.repository_service_exceptions

Exception hierarchy:

RepositoryServiceError(message='', detail=None)

Bases: BaseServiceError

Base exception for all errors that occur within the repository service.

Attributes:

Name Type Description
code

A stable machine-readable string identifying the specific error.

message str

A human-readable description of what went wrong and, where possible, how to resolve it.

detail dict[str, JsonValue] | None

Optional structured context about the error, or None when there is none.

code = 'REPOSITORY_SERVICE_ERROR' class-attribute instance-attribute

ResourceNotFoundError(resource_id)

Bases: RepositoryServiceError

Raised when the requested resource was not found in the repository service.

code = 'RESOURCE_NOT_FOUND_ERROR' class-attribute instance-attribute

ResourceAlreadyExistsError(resource_id)

Bases: RepositoryServiceError

Raised when a resource with the provided resource ID already exists in the repository service.

code = 'RESOURCE_ALREADY_EXISTS_ERROR' class-attribute instance-attribute

ResourceIDReservationNotFoundError(resource_id)

Bases: RepositoryServiceError

Raised when a resource ID passed to create_file or create_directory has no matching reservation.

code = 'RESOURCE_ID_RESERVATION_NOT_FOUND_ERROR' class-attribute instance-attribute

RepositoryMetadataFileError(message='', detail=None)

Bases: RepositoryServiceError

Base exception for every failure to get the repository metadata file's data on or off disk.

Catch this to handle "the repository metadata did not make it in or out" without caring why. To distinguish a filesystem fault from a bad file, catch RepositoryMetadataFileSystemError or RepositoryMetadataFileContentError instead.

code = 'REPOSITORY_METADATA_FILE_ERROR' class-attribute instance-attribute

RepositoryMetadataFileSystemError(operation, path, underlying_error)

Bases: RepositoryMetadataFileError

Raised when a filesystem operation on the repository metadata file fails.

This covers every way the filesystem can refuse the operation: the file does not exist, the process lacks the required permissions, the path points at a directory, the disk is full. They share one type because no caller can act differently on any of them. All of them mean the operation did not happen, and the specific cause is carried in message and detail for whoever has to fix it.

A file the filesystem hands over successfully but whose contents are wrong is reported separately, through RepositoryMetadataFileContentError.

code = 'REPOSITORY_METADATA_FILE_SYSTEM_ERROR' class-attribute instance-attribute

RepositoryMetadataFileContentError(message='', detail=None)

Bases: RepositoryMetadataFileError

Base exception for all errors that occur when the repository metadata .repository.json file's contents are wrong.

The filesystem handed the file's bytes over successfully, so this is fixed by correcting the file rather than by changing the state of the machine or the configured path.

code = 'REPOSITORY_METADATA_FILE_CONTENT_ERROR' class-attribute instance-attribute

RepositoryMetadataFileEncodingError(path, underlying_error)

Bases: RepositoryMetadataFileContentError

Raised when the repository metadata file's bytes cannot be decoded as UTF-8.

code = 'REPOSITORY_METADATA_FILE_ENCODING_ERROR' class-attribute instance-attribute

RepositoryMetadataFileJSONError(path)

Bases: RepositoryMetadataFileContentError

Raised when the repository metadata file is not valid JSON during repository metadata loading.

code = 'REPOSITORY_METADATA_FILE_JSON_ERROR' class-attribute instance-attribute

RepositoryMetadataFileSchemaError(path, validation_error_message)

Bases: RepositoryMetadataFileContentError

Raised when the repository metadata file does not conform to the expected JSON schema during repository metadata loading.

code = 'REPOSITORY_METADATA_FILE_SCHEMA_ERROR' class-attribute instance-attribute

RepositoryMetadataFileResourceDataSchemaError(path, resource_id, validation_error_message)

Bases: RepositoryMetadataFileContentError

Raised when the data field of a repository resource in the repository metadata file does not conform to the expected JSON schema during repository metadata loading.

code = 'REPOSITORY_METADATA_FILE_RESOURCE_DATA_SCHEMA_ERROR' class-attribute instance-attribute

RepositoryMetadataFileUnsyncedError(path, unsynced_resource_ids)

Bases: RepositoryMetadataFileContentError

Raised when the repository metadata file is out of sync with the actual contents of the repository directory.

The file parses and validates: what is wrong is that it disagrees with the directory. It sits under RepositoryMetadataFileContentError because the remedy is still to the file's contents rather than to the state of the machine.

code = 'REPOSITORY_METADATA_FILE_UNSYNCED_ERROR' class-attribute instance-attribute