Send raw integer bytes_transferred to backup_runs

The datatable column is type number, so the human-formatted string
('20.96 KB') was rejected with a validation error (seen on the first
vaultwarden-org-export report). Format for display in the reporter,
not in the payload. Deployed copy in ~/.local/bin updated to match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0133oyd1U9XxpLQU3UHMzUyy
This commit is contained in:
jared 2026-07-10 11:10:24 -04:00
parent f9579e925f
commit 79f4825e4b
2 changed files with 6 additions and 4 deletions

View File

@ -69,7 +69,9 @@ class PayloadBuilder
machine: @options[:machine],
destination: @options[:destination],
status: @options[:status],
bytes_transferred: ByteFormatter.format(@options[:bytes]),
# Raw integer: the backup_runs datatable column is type number;
# human formatting belongs in the reporter, not the payload.
bytes_transferred: @options[:bytes],
snapshot_id: @options[:snapshot],
log_path: @options[:log_path],
notes: @options[:notes]

View File

@ -43,9 +43,9 @@ class PayloadBuilderTest < Minitest::Test
assert_match(/\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z\z/, payload[:timestamp])
end
def test_formats_bytes_to_human_readable
def test_sends_raw_integer_bytes
payload = PayloadBuilder.new(base_options.merge(bytes: 1_073_741_824)).build
assert_equal '1.00 GB', payload[:bytes_transferred]
assert_equal 1_073_741_824, payload[:bytes_transferred]
end
def test_omits_nil_optional_fields
@ -64,7 +64,7 @@ class PayloadBuilderTest < Minitest::Test
notes: 'snapshot abc12345 saved'
)
payload = PayloadBuilder.new(opts).build
assert_equal '1.00 MB', payload[:bytes_transferred]
assert_equal 1_048_576, payload[:bytes_transferred]
assert_equal 'abc12345', payload[:snapshot_id]
assert_equal '/home/jared/.local/log/restic/2026-05-07.log', payload[:log_path]
assert_equal 'snapshot abc12345 saved', payload[:notes]