Freika/dawarich · error · StandardError
Data file not found in archive: data.json
Error message
Data file not found in archive: data.json
What it means
StandardError raised by Users::ImportData::V1Handler#process when data.json is absent from the extracted import directory. In the normal flow the v1 handler is only selected because detect_format_version saw data.json exist, so reaching this raise means the file vanished between detection and processing, the entry was skipped during extraction (name rejected by sanitize_zip_entry_name, or oversized), or the handler was invoked directly with the wrong directory.
Source
Thrown at app/services/users/import_data/v1_handler.rb:42
# "places": [...]
# }
class Users::ImportData::V1Handler
STREAM_BATCH_SIZE = 5000
STREAMED_SECTIONS = %w[places visits points].freeze
def initialize(user, import_directory, import_stats)
@user = user
@import_directory = import_directory
@import_stats = import_stats
@expected_counts = nil
end
def process
Rails.logger.info "Processing v1 format archive for user: #{user.email}"
json_path = import_directory.join('data.json')
raise StandardError, I18n.t('services.users.import_data.v1_handler.data_file_missing') unless File.exist?(json_path)
initialize_stream_state
handler = ::JsonStreamHandler.new(self)
parser = Oj::Parser.new(:saj, handler: handler)
File.open(json_path, 'rb') do |io|
parser.load(io)
end
finalize_stream_processing
rescue Oj::ParseError => e
raise StandardError, I18n.t('services.users.import_data.v1_handler.invalid_json', message: e.message)
rescue IOError => e
raise StandardError, I18n.t('services.users.import_data.v1_handler.read_failed', message: e.message)
end
attr_reader :expected_countsView on GitHub (pinned to 97fad417c5)
Solutions
- Verify the extraction directory actually contains data.json (Dir.children of the tmp/import_* dir) before processing
- Inspect the zip (unzip -l) and confirm an entry named exactly data.json at the root
- Run the import end-to-end through Users::ImportData#import instead of the handler directly
- Ensure nothing prunes Rails tmp/ while user-data imports run
Example fix
# before: invoking the handler directly against an arbitrary directory
Users::ImportData::V1Handler.new(user, Pathname.new('tmp/extracted'), stats).process
# after: go through the orchestrator, which detects format and extracts first
Users::ImportData.new(user, 'path/to/export.zip').import Defensive patterns
Strategy: validation
Validate before calling
json_path = import_directory.join('data.json')
raise ArgumentError, 'data.json missing from extraction directory' unless File.exist?(json_path) Type guard
def v1_importable?(import_directory)
File.file?(import_directory.join('data.json'))
end Try / catch
begin
Users::ImportData::V1Handler.new(user, dir, stats).process
rescue StandardError => e
# message distinguishes missing-file vs invalid-json vs read-failure
Rails.logger.error("v1 import failed: #{e.message}")
raise
end Prevention
- Always drive the handler through Users::ImportData#import so extraction and detection share one directory
- Never invoke V1Handler against an arbitrary path in production code
- Keep tmp cleanup jobs away from import directories during imports
When it happens
Trigger: Console/test invocation of V1Handler with a directory lacking data.json; a zip whose data.json entry has a name that gets sanitized to nil (contains '..' or is absolute); the tmp/import_* working directory being cleaned mid-run.
Common situations: Development against the handler in isolation, archives crafted with unusual entry names, or tmp-cleanup jobs racing a long import.
Related errors
- Manifest file not found in archive: manifest.json
- Unknown export format: neither manifest.json nor data.json f
- Unsupported export format version: %{version}
- Invalid JSON format in data file: %{message}
- Failed to read JSON data: %{message}
AI-assisted analysis of Freika/dawarich@97fad417c5 (2026-08-21).
Data as JSON: /api/errors/e0218b91e88c9c7b.
Report an issue: GitHub.