fix: bug while creating a new profile

This commit is contained in:
2026-07-02 11:41:53 +02:00
parent 93c8f6b9d3
commit 6ec31b61ce
3 changed files with 12 additions and 3 deletions
+1
View File
@@ -609,6 +609,7 @@ func (a *App) startup(ctx context.Context) {
// to a separate cat.log in the old HamLog folder, which users couldn't find). // to a separate cat.log in the old HamLog folder, which users couldn't find).
cat.LogSink = applog.Printf cat.LogSink = applog.Printf
audio.LogSink = applog.Printf // capture audio-goroutine panics in the app log audio.LogSink = applog.Printf // capture audio-goroutine panics in the app log
extsvc.LogSink = applog.Printf // log raw QRZ (and other) service responses for diagnosis
applog.Printf("startup: data dir = %s", dataDir) applog.Printf("startup: data dir = %s", dataDir)
// The local SQLite file ALWAYS holds per-operator configuration — settings, // The local SQLite file ALWAYS holds per-operator configuration — settings,
// station profiles, rigs/antennas, cluster nodes, UDP, QSL templates, award // station profiles, rigs/antennas, cluster nodes, UDP, QSL templates, award
+4 -2
View File
@@ -133,8 +133,10 @@ const emptyProfile = (): Profile => ({
is_active: false, is_active: false,
sort_order: 0, sort_order: 0,
db: { backend: '', host: '', port: 3306, user: '', password: '', database: '' }, db: { backend: '', host: '', port: 3306, user: '', password: '', database: '' },
created_at: '' as any, // Server-managed timestamps — send null (NOT "") so Go's time.Time unmarshal
updated_at: '' as any, // leaves the zero value instead of failing to parse an empty RFC3339 string.
created_at: null as any,
updated_at: null as any,
}); });
interface Props { interface Props {
+6
View File
@@ -16,6 +16,10 @@ import (
// subscription used elsewhere for callsign data — they're different keys. // subscription used elsewhere for callsign data — they're different keys.
const qrzAPIURL = "https://logbook.qrz.com/api" const qrzAPIURL = "https://logbook.qrz.com/api"
// LogSink receives diagnostics such as raw QRZ responses. Set to applog.Printf
// at startup; defaults to a no-op so the package is usable without wiring.
var LogSink = func(string, ...any) {}
// UploadQRZ pushes one ADIF record to the QRZ.com logbook identified by // UploadQRZ pushes one ADIF record to the QRZ.com logbook identified by
// apiKey. It returns OK when the QSO is inserted or already present // apiKey. It returns OK when the QSO is inserted or already present
// (QRZ reports a duplicate as a FAIL with a "duplicate" reason, which we // (QRZ reports a duplicate as a FAIL with a "duplicate" reason, which we
@@ -67,6 +71,7 @@ func UploadQRZ(ctx context.Context, client *http.Client, apiKey, adifRecord stri
if resp.StatusCode != http.StatusOK { if resp.StatusCode != http.StatusOK {
return UploadResult{}, fmt.Errorf("qrz: http %d: %s", resp.StatusCode, strings.TrimSpace(string(body))) return UploadResult{}, fmt.Errorf("qrz: http %d: %s", resp.StatusCode, strings.TrimSpace(string(body)))
} }
LogSink("qrz: INSERT raw response: %s", strings.TrimSpace(string(body)))
return parseQRZResponse(string(body)) return parseQRZResponse(string(body))
} }
@@ -171,6 +176,7 @@ func TestQRZ(ctx context.Context, client *http.Client, apiKey string) (string, e
} }
defer resp.Body.Close() defer resp.Body.Close()
body, _ := io.ReadAll(io.LimitReader(resp.Body, 64*1024)) body, _ := io.ReadAll(io.LimitReader(resp.Body, 64*1024))
LogSink("qrz: STATUS raw response: %s", strings.TrimSpace(string(body)))
vals, err := url.ParseQuery(strings.TrimSpace(string(body))) vals, err := url.ParseQuery(strings.TrimSpace(string(body)))
if err != nil { if err != nil {
return "", fmt.Errorf("qrz: bad response: %w", err) return "", fmt.Errorf("qrz: bad response: %w", err)