Skip to content

GET /api/campaigns — query parameter is executed as tsquery instead of SQL (unlike subscribers endpoint) #2772

@eightam

Description

@eightam

Version:

  • listmonk: v5.1.0
  • OS: Docker on dokploy

GET /api/campaigns — query parameter is executed as tsquery instead of SQL

Using the query parameter on GET /api/campaigns does not behave as documented.
The documentation states that query should accept a SQL expression (similar to the subscribers endpoint), but on my instance the value is interpreted as a tsquery full-text expression instead.

Example request

GET /api/campaigns?query=campaigns.uuid = '259c94b2-5568-4a61-a37a-9f240b3a621a'&per_page=all

Actual response

500 - pq: syntax error in tsquery: "%campaigns.uuid&=&'259c94b2-5568-4a61-a37a-9f240b3a621a'%"

This shows the string is being rewritten into a tsquery ("%campaigns.uuid&=&'…'%") instead of being used as a SQL WHERE fragment.

Difference to subscribers endpoint

The subscribers endpoint does correctly treat query= as SQL, e.g.:

GET /api/subscribers?query=subscribers.name LIKE 'Test%' AND subscribers.attribs->>'city' = 'Bengaluru'

This works as expected.

Expected behaviour

  • GET /api/campaigns should accept SQL expressions in the query parameter, consistent with the documentation and with the subscribers API.

Actual behaviour

  • Listmonk interprets query as a tsquery string, producing syntax errors when valid SQL is provided.
  • Filtering on fields like campaigns.uuid becomes impossible.

Would be great to know whether this is a bug, a regression, or an intended change in newer versions.
Or is there another way to query campaigns by uuid?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions