Skip to content

Fix InfluxDB hook methods failing when called before get_conn - #71705

Merged
eladkal merged 1 commit into
apache:mainfrom
jayamanikharyono:fix-influxdb-hook-uninitialised-client
Aug 20, 2026
Merged

eladkal merged 1 commit into
apache:mainfrom
jayamanikharyono:fix-influxdb-hook-uninitialised-client

Conversation

@jayamanikharyono

Copy link
Copy Markdown
Contributor

InfluxDBHook.write() and the five bucket/organization methods read self.client directly, but that attribute stays None until something calls get_conn(). Any Dag that calls them on a fresh hook fails with AttributeError: 'NoneType' object has no attribute 'write_api'.
They now take the client from self.get_conn(), which is what query() and query_to_df() in the same class have always done. get_conn() already returns a cached client, so this opens no additional connections.

Three further defects in the same hook are fixed alongside it:

  • get_uri() fell back to port 7687 — Neo4j's Bolt port — when the connection carried no explicit port, so a connection created without one pointed at an unreachable address. It now defaults to 8086 for http and 443 for https, matching InfluxDB3Hook.get_uri() in the same provider.
  • create_bucket() accepts a retention_rules argument and then passed a hardcoded None to the client, silently discarding whatever the caller supplied.
  • The system Dag reads influxdb_hook.org_name, which has not existed since the constructor moved to self.extras. It also passed an organization name into create_bucket()'s org_id parameter, so it now resolves the name to an
    ID first.

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

Six client-backed methods read self.client directly, so any Dag that
called them without first calling get_conn() crashed with an
AttributeError. The unit tests assigned the client attribute by hand,
which hid the failure from CI. The default port also pointed at Neo4j's
Bolt port, making a connection without an explicit port unusable.
@fat-catTW

Copy link
Copy Markdown
Contributor

LGTM!
Thanks for contribution.

@eladkal

eladkal commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

cc @arpitrathore can you take a look?

@arpitrathore

Copy link
Copy Markdown
Contributor

LGTM!
Thanks for fixing the uninitialized client across the hook methods, the default port (8086/443, matching InfluxDB3Hook), and create_bucket silently dropping retention_rules. Good call removing the hand-assigned self.client from the tests, that's what turns them into actual regression tests.

@eladkal
eladkal merged commit 306b831 into apache:main Aug 20, 2026
79 checks passed
Miretpl pushed a commit to Miretpl/airflow that referenced this pull request Aug 20, 2026
…71705)

Six client-backed methods read self.client directly, so any Dag that
called them without first calling get_conn() crashed with an
AttributeError. The unit tests assigned the client attribute by hand,
which hid the failure from CI. The default port also pointed at Neo4j's
Bolt port, making a connection without an explicit port unusable.
imrichardwu pushed a commit to imrichardwu/airflow that referenced this pull request Sep 11, 2026
…71705)

Six client-backed methods read self.client directly, so any Dag that
called them without first calling get_conn() crashed with an
AttributeError. The unit tests assigned the client attribute by hand,
which hid the failure from CI. The default port also pointed at Neo4j's
Bolt port, making a connection without an explicit port unusable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants