Skip to content

bug: AttributeError: 'str' object has no attribute 'append' #294

Closed
@florian-ernst-alan

Description

@florian-ernst-alan

I updated my Meltano version recently (I think I was on the last Meltano 2), and updated the taps as well. Now I cannot sync my Postgres table anymore.

Running meltano invoke tap-postgres--backend raises the following error:

~/meltano_test main +12 !3 ?4meltano invoke tap-postgres--fr-apimeltano_test3.10  17:57:53
2023-11-21T16:58:57.573152Z [info     ] Environment 'default' is active
Traceback (most recent call last):
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/bin/tap-postgres", line 8, in <module>
    sys.exit(TapPostgres.cli())
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/singer_sdk/tap_base.py", line 494, in invoke
    tap = cls(
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/tap_postgres/tap.py", line 47, in __init__
    super().__init__(*args, **kwargs)
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/singer_sdk/tap_base.py", line 628, in __init__
    super().__init__(*args, **kwargs)
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/singer_sdk/tap_base.py", line 103, in __init__
    self.setup_mapper()
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/singer_sdk/tap_base.py", line 173, in setup_mapper
    self.mapper.register_raw_streams_from_catalog(self.catalog)
  File "/Users/florian.ernst/meltano_test/.meltano/extractors/tap-postgres/venv/lib/python3.10/site-packages/tap_postgres/tap.py", line 535, in catalog
    property.type.append("null")
AttributeError: 'str' object has no attribute 'append'

Here is my meltano.yml config:

# Defined here so all our Postgres extractors can inherit from it
plugins:
  extractors:
  - name: tap-postgres
    variant: meltanolabs
    pip_url: git+https://github.com/MeltanoLabs/tap-postgres.git
  - name: tap-postgres--backend
    inherit_from: tap-postgres
    config:
      host: foo.eu-central-1.rds.amazonaws.com
      port: 5432
      user: meltano
      database: main
    load_schema: meltano__backend
    select:
      - "*.*"
      - "!public-activity.*"
      - "!public-pg_*.*"
      - "!be-*.*"
      - "!es-*.*"
      - "!mind-*.*"
      - "!postgres-*.*"
    metadata:
      "*":
        replication-method: LOG_BASED
      "public-databasechangelog":
        replication-method: FULL_TABLE

After some manual debugging, I noticed the issue came from this line in tap_postgres/tap.py:

                for property in new_stream.schema.properties.values():
                    if "null" not in property.type:
                        stream_modified = True
                        property.type.append("null")

I changed the code to check what property was failing: the property is "data". There are several instances of "data" property in my .meltano/run/tap-postgres--backend/tap.properties.json file, and they are all equal to:

"data": {
  "properties": {},
  "type": "object"
},

Indeed, type is a string and not an object, so calling the append method fails.
The weird thing is that I have another Postgres tap running just fine (also inheriting from tap-postgres). Any idea why this happens, and how to fix it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions