fix(sync): emit MHz frequency to LoTW + QRZ instead of dividing by 1M#212
Merged
Conversation
contacts.frequency is numeric(10,6) and stores MHz directly — the column precision can't physically hold Hz for HF (14.205 MHz in Hz is 14205000, which needs 8 integer digits; the column allows 4). The form, ADIF import, and QRZ download all write MHz. Both upload paths assumed Hz and divided by 1_000_000: LoTW (src/lib/lotw.ts): freqToMhz(14.205) = 0.000014 MHz QRZ (src/lib/qrz.ts): (14.205 / 1000000).toString() = "0.0000142..." For LoTW that produced a .tq8 whose canonical sign-string used the wrong frequency. The signature still verified (same wrong value on both sides), so LoTW accepted the upload and the app marked contacts lotw_qsl_sent='Y'. LoTW then silently dropped each QSO because 0.000014 MHz isn't a valid amateur frequency — uploads "succeeded" but nothing appeared on the LoTW site. The author of #185 chased this confusion the wrong way in the upload-route comment, inferring Hz from the QRZ uploader's matching bug. Fix: - Rename freqToMhz → formatFreqMhz, drop the /1_000_000 (input is MHz). - Same for contactToQRZFormat in qrz.ts. - Replace the misleading "stored in Hz" comment in the upload route. After this lands, contacts uploaded with the bad frequency are still marked lotw_qsl_sent='Y'/'qrz_sync_status'='synced' in the DB and won't re-upload. PR description has a one-liner to reset them. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Both LoTW and QRZ uploads have been silently dropping every QSO since #185. They divide
contacts.frequencyby 1,000,000 thinking it's Hz, but the column (numeric(10, 6)) physically can't hold Hz for HF —14.205 MHzin Hz is14_205_000, which needs 8 integer digits, the column allows 4. The form, ADIF import, and QRZ download all write MHz.For LoTW that meant the
.tq8carried<FREQ:8>0.000014for a 14.205 MHz QSO. The canonical sign-string used the same wrong value, so the signature verified cleanly on both sides — LoTW accepted the upload, the app marked the rowslotw_qsl_sent='Y', and LoTW silently discarded each QSO because0.000014 MHzisn't a valid amateur frequency. The uploads "succeeded" but nothing appeared on the LoTW site.QRZ has the same bug and is almost certainly also dropping these silently.
The author of #185 left a comment (
upload/route.ts:250-253) chasing this exact confusion the wrong way — they inferred Hz from QRZ's(contact.frequency / 1_000_000)line, when actually that was the bug.Fix
src/lib/lotw.ts: renamefreqToMhz(freqHz)→formatFreqMhz(freqMhz)and drop the/ 1_000_000(input is already MHz). Update all 4 callers (signing + ADIF emit, freq + freq_rx).src/lib/qrz.ts: same change incontactToQRZFormat.src/app/api/lotw/upload/route.ts: replace the misleading comment.Cleanup after merging
QSOs uploaded with the bad frequency are now marked
lotw_qsl_sent='Y'/qrz_qsl_sent='Y'in the DB, so a fresh sync skips them. Reset the rows affected by the broken builds (#185 merged 2026-05-10):Adjust the date if you know exactly when the bad builder first ran. Then trigger a manual upload on /lotw (or wait for the 01:00 UTC cron) and the QSOs should land.
Test plan
🤖 Generated with Claude Code