Skip to content

TypeError in PGSync: Incorrect List Indexing During Primary Key Update #571

@sagkhr23

Description

@sagkhr23

PGSync Version:
3.2.0
PostgreSQL Version:
15.4
Elasticsearch/OpenSearch Version:
8.6.1
Redis Version:
7.0.0
Python Version:
3.9

Problem Description:
When changing the primary key for a document, a code block executes the following line:

python
doc["_routing"] = old_values[self.routing]

Here, old_values is a list, and self.routing is a string. If self.routing is not convertible to an integer, it raises a TypeError.

Error Message:
ERROR:pgsync.search_client: Exception list indices must be integers or slices, not str
Traceback (most recent call last):
File "/code/pgsync/search_client.py", line 141, in bulk
self._bulk(
File "/code/pgsync/search_client.py", line 210, in _bulk
for _ in self.parallel_bulk(
File "/usr/local/lib/python3.9/site-packages/elasticsearch/helpers/actions.py", line 472, in parallel_bulk
for result in pool.imap(
File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 870, in next
raise value
File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 144, in _helper_reraises_exception
raise ex
File "/usr/local/lib/python3.9/multiprocessing/pool.py", line 388, in _guarded_task_generation
for i, x in enumerate(iterable):
File "/usr/local/lib/python3.9/site-packages/elasticsearch/helpers/actions.py", line 155, in _chunk_actions
for action, data in actions:
File "/code/pgsync/sync.py", line 977, in _payloads
filters = self._update_op(
File "/code/pgsync/sync.py", line 745, in _update_op
doc["_routing"] = old_values[self.routing]
TypeError: list indices must be integers or slices, not str

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