From 79f4825e4b45a83484a4a645d8f28470dc523dbb Mon Sep 17 00:00:00 2001 From: jared Date: Fri, 10 Jul 2026 11:10:24 -0400 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_0133oyd1U9XxpLQU3UHMzUyy --- scripts/notify_backup.rb | 4 +++- scripts/notify_backup_test.rb | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/notify_backup.rb b/scripts/notify_backup.rb index da95126..f493b96 100644 --- a/scripts/notify_backup.rb +++ b/scripts/notify_backup.rb @@ -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] diff --git a/scripts/notify_backup_test.rb b/scripts/notify_backup_test.rb index 30e340b..3559ff9 100644 --- a/scripts/notify_backup_test.rb +++ b/scripts/notify_backup_test.rb @@ -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]