Skip to content

fix: stop default_tags from one client leaking into other clients' WriteApi#710

Open
arpitjain099 wants to merge 1 commit into
influxdata:masterfrom
arpitjain099:chore/default-tags-isolation
Open

fix: stop default_tags from one client leaking into other clients' WriteApi#710
arpitjain099 wants to merge 1 commit into
influxdata:masterfrom
arpitjain099:chore/default-tags-isolation

Conversation

@arpitjain099

@arpitjain099 arpitjain099 commented Jun 28, 2026

Copy link
Copy Markdown

Closes #686

Proposed Changes

The write_api factories and the WriteApi/WriteApiAsync constructors defaulted point_settings to PointSettings(). Mutable default, so the same instance is shared across calls that omit it, and _BaseWriteApi.init mutates it in place when the client has default_tags. So one client's default_tags leak into other clients' write APIs, even ones that set none. Same thing on the async path.

Did what the issue suggested: default the four point_settings args to None and create a fresh PointSettings in _BaseWriteApi.init when it's None. Also dropped the now-unused PointSettings imports.

Added a regression test (plain client, then a client with default_tags, then reuse the plain client and check its tags are still empty). Fails on main, passes with the fix. flake8 clean.

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • pytest tests completes successfully
  • Commit messages are conventional
  • Sign CLA (if not already signed)

The write_api() factories and WriteApi.__init__ used PointSettings() as a
default argument value, so every call that omitted point_settings shared one
PointSettings instance created at function-definition time. _BaseWriteApi then
mutated that shared instance in place with the client's default_tags, which
caused one client's default_tags to leak into every other client's WriteApi,
including clients with no default_tags of their own. The async path had the
identical bug.

Change the four point_settings defaults from PointSettings() to None and build
a fresh PointSettings in _BaseWriteApi when none is supplied. Add a regression
test asserting no cross-client leak.

Closes influxdata#686

Signed-off-by: arpitjain099 <arpitjain099@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using the default_tags argument of InfluxDBClient alters the tags for any write_api by any client

1 participant