fix(observers): preserve advert pages with missing origin keys (#138)

* test(observers): cover adverts with a missing origin key

* fix(observers): preserve advert pages with missing origin keys
This commit is contained in:
n30nex
2026-09-18 06:17:33 -04:00
committed by GitHub
parent e15f873597
commit b44769bef8
4 changed files with 90 additions and 2 deletions
+1
View File
@@ -151,6 +151,7 @@ type Querier interface {
ListObservationsForPacket(ctx context.Context, packetHash []byte) ([]ListObservationsForPacketRow, error)
// Returns advert packets (payload_type=4) heard by a specific observer.
// Pass cursor=0 to start from the beginning, or the last seen id for pagination.
// Keep missing-origin adverts; the generated key field expects a string, not NULL.
ListObserverAdverts(ctx context.Context, arg ListObserverAdvertsParams) ([]ListObserverAdvertsRow, error)
// Pass cursor=0 to start from the beginning, or the last seen observer's rownum for pagination.
// Note: observers use UUID PKs so we order by last_seen and use a keyset on last_seen+id.
+2 -1
View File
@@ -2860,7 +2860,7 @@ SELECT
po.snr,
po.hop_count,
n.name AS node_name,
encode(p.origin_pubkey, 'hex') AS node_public_key
COALESCE(encode(p.origin_pubkey, 'hex'), '')::text AS node_public_key
FROM packet_observations po
JOIN packets p ON p.packet_hash = po.packet_hash
LEFT JOIN nodes n ON n.public_key = p.origin_pubkey
@@ -2892,6 +2892,7 @@ type ListObserverAdvertsRow struct {
// Returns advert packets (payload_type=4) heard by a specific observer.
// Pass cursor=0 to start from the beginning, or the last seen id for pagination.
// Keep missing-origin adverts; the generated key field expects a string, not NULL.
func (q *Queries) ListObserverAdverts(ctx context.Context, arg ListObserverAdvertsParams) ([]ListObserverAdvertsRow, error) {
rows, err := q.db.Query(ctx, listObserverAdverts, arg.ObserverID, arg.Column2, arg.Limit)
if err != nil {