Skip to content

ListObserverAdverts 500s when origin_pubkey is NULL #106

Description

@MrAlders0n

Symptom. GET /api/v1/observers/{id}/adverts?limit=50 returns 500 for some observers (seen on analyzer.meshmapper.net for at least four observers on 2026-09-02/03). The app log has the cause:

api: ListObserverAdverts failed: can't scan into dest[9] (col: node_public_key): cannot scan NULL into *string
api: error 500: internal server error

Cause. db/queries/queries.sql:263-284 (ListObserverAdverts) selects encode(p.origin_pubkey, 'hex') AS node_public_key. sqlc types that column as a non-null string, but packets.origin_pubkey can be NULL, so any advert row without an origin pubkey breaks the whole page.

Fix options.

  • COALESCE(encode(p.origin_pubkey, 'hex'), '') AS node_public_key, or
  • make the column nullable in the generated struct (::text + sqlc.narg/pgtype.Text) and expose it as *string in the API type, or
  • AND p.origin_pubkey IS NOT NULL if such rows are never meaningful as adverts.

Whichever is chosen, a NULL in one row should not fail the endpoint. A regression test with one NULL-pubkey advert would catch this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2-mediumMedium priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions