Skip to content

Transactions Typesense collection uses reference: "balances.balance_id" instead of reference: "balances.id", causing all transaction indexing to fail #280

@DaveMaks

Description

@DaveMaks

Describe the bug

The blnk workers process fails to index every transaction into Typesense with a 400 error. The root cause is that the transactions collection schema is created with join references pointing to balances.balance_id, but Typesense requires join references to target the document's primary key field (id).

To Reproduce

  1. Start blnk with Typesense enabled (BLNK_TYPESENSE_DNS set)
  2. Create a ledger, balance, and process any transaction
  3. Observe worker logs

4. Error log:

level=error msg="Error indexing batch txn_XXXX: failed to index primary
transactions/txn_XXXX: failed to upsert document in Typesense:
status: 400 response: {\"message\":\"Referenced field `balance_id` not
found in the collection `balances`.\"}"

Expected behavior

Transactions are indexed into Typesense successfully.

Root cause

The transactions Typesense collection is created with:

{ "name": "source",      "reference": "balances.balance_id" }
{ "name": "destination", "reference": "balances.balance_id" }

Typesense's JOIN feature requires the referenced field to be the primary key (id) of the target collection, not just any indexed field. Although balances documents contain a balance_id field (with the same value as id), Typesense rejects it as a join target.

Fix

Change the references to point to balances.id:

{ "name": "source",      "reference": "balances.id" }
{ "name": "destination", "reference": "balances.id" }

This works because blnk already sets the Typesense document id equal to balance_id when indexing balances.

Verification

After manually recreating the transactions collection with reference: "balances.id", upserts succeed immediately and the worker stops producing errors.

Environment

  • blnk version: 0.14.0 (jerryenebeli/blnk:latest)
  • Typesense version: 29.1
  • Deployment: Docker Compose

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions