gitlabhq/gitlabhq · error · Import::BulkImports::FileDownloadStrategy::ServiceError
File size %{size} exceeds limit of %{limit}
Error message
File size %{size} exceeds limit of %{limit} What it means
Raised via Import::BulkImports::FileDownloadStrategy#log_and_raise_error from validate_size! (app/services/import/bulk_imports/file_download_strategy.rb:50) as ServiceError when a downloaded relation/export file's size exceeds the strategy's file_size_limit (a limit of 0 means unlimited). The message is formatted with ActiveSupport::NumberHelper to human-readable units, e.g. 'File size 2.5 GB exceeds limit of 1 GB'. Like the symlink case it logs a warning through BulkImports::Logger before raising.
Source
Thrown at app/services/import/bulk_imports/file_download_strategy.rb:27
def download_file(filepath)
Gitlab::PathTraversal.check_path_traversal!(filepath)
perform_download(filepath)
validate_symlink(filepath)
end
def validate!
raise Gitlab::AbstractMethodError
end
def log_and_raise_error(message)
log_params = { message: message }
log_params.merge!(log_error_params)
logger.warn(log_params)
raise ServiceError, message
end
private
def perform_download(_filepath)
raise Gitlab::AbstractMethodError
end
def file_size_limit
raise Gitlab::AbstractMethodError
end
def validate_symlink(filepath)
return unless Gitlab::Utils::FileInfo.linked?(filepath)
File.delete(filepath)
log_and_raise_error('Invalid downloaded file')
endView on GitHub (pinned to 55ee20384a)
Solutions
- Identify the limit from the error text (the %{limit} value) and the offending file size, then raise the corresponding import/export size limit setting on the destination instance (e.g. group/project import size limits or Max import size in Application settings).
- Reduce the payload: split the migration into smaller top-level groups or exclude heavy relations, so each archive stays under the cap.
- Re-run the bulk import after the change; previously oversized downloads re-attempt cleanly.
- If the limit is intentionally strict, filter out the oversized entity and report it rather than retrying.
Example fix
# before — destination limit 1 GB, export is 2.5 GB strategy.download_file(tmp_path) # => ServiceError: File size 2.5 GB exceeds limit of 1 GB # after — raise the instance import cap, then re-import # (Admin Area → Settings → General → Account and limit → Maximum import size, or) # rails console: ApplicationSetting.first.update!(max_import_size: 10240) # MiB strategy.download_file(tmp_path)
Defensive patterns
Strategy: try-catch
Validate before calling
# If the size is knowable beforehand, compare against the same limit limit = strategy.file_size_limit if limit > 0 && remote_size > limit # split the export or raise the limit before downloading end
Try / catch
begin strategy.download_file(filepath) rescue Import::BulkImports::FileDownloadStrategy::ServiceError => e # parse 'File size X exceeds limit of Y' — raise the instance import # size limit or split the migration into smaller groups, then retry end
Prevention
- Set Max import size on the destination with headroom over the largest group's relation export.
- Pre-compute export sizes on the source instance before planning a migration.
- Split very large top-level groups into per-subgroup imports to stay under per-file caps.
When it happens
Trigger: A bulk import / direct transfer downloads an export or relation archive whose byte size is larger than the configured limit enforced by the concrete strategy (validate_size! is called with the Content-Length or written size during perform_download). Typical triggers: very large groups whose relation exports grew past the instance's import size cap, or limits lowered after previous imports succeeded.
Common situations: Enterprise migrations of monolithic groups; administrators tightening max import size settings; export bloat from large issues/MR diffs; a different setting applying on the destination instance than the source.
Related errors
- state must be one of: #{Namespace::SHARED_RUNNERS_SETTINGS.j
- Failed to load Web IDE config file '#{WEBIDE_CONFIG_FILE}' f
- Metadata contains no mapping for entity path '#{source_full_
- Invalid downloaded file
- Missing OAuth configuration for GitHub.
AI-assisted analysis of gitlabhq/gitlabhq@55ee20384a (2026-08-21).
Data as JSON: /api/errors/781966f510aec8c4.
Report an issue: GitHub.