InfluxDB Publisher v2: ApiException generated when invalid token is used
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 19
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Description
In the InfluxDB Publisher v2 agent, if an invalid token is used, then the agent crashes with this error (sorry, txaio formatting is awful):
2026-03-26T20:42:35+0000 startup-op: launching record
2026-03-26T20:42:35+0000 start called for record
2026-03-26T20:42:35+0000 record:0 Status is now "starting".
2026-03-26T20:42:35+0000 record:0 Status is now "running".
2026-03-26T20:42:35+0000 gzip encoding enabled: False
2026-03-26T20:42:35+0000 data protocol: line
2026-03-26T20:42:35+0000 Unable to format event {'log_logger': <Logger 'ocs.ocs_agent.OCSAgent'>, 'log_level': <LogLevel=info>, 'log_namespace': 'ocs.ocs_agent.OCSAgent', 'log_source': None, 'log_format': 'record:0 CRASH: [Failure instance: Traceback: <class \'influxdb_client.rest.ApiException\'>: (401)\nReason: Unauthorized\nHTTP response headers: HTTPHeaderDict({\'Content-Type\': \'application/json; charset=utf-8\', \'X-Influxdb-Build\': \'OSS\', \'X-Influxdb-Version\': \'v2.7.12\', \'X-Platform-Error-Code\': \'unauthorized\', \'Date\': \'Thu, 26 Mar 2026 20:42:35 GMT\', \'Content-Length\': \'55\'})\nHTTP response body: {"code":"unauthorized","message":"unauthorized access"}\n\n/opt/venv/lib/python3.10/site-packages/twisted/python/threadpool.py:269:inContext\n/opt/venv/lib/python3.10/site-packages/twisted/python/threadpool.py:285:<lambda>\n/opt/venv/lib/python3.10/site-packages/twisted/python/context.py:117:callWithContext\n/opt/venv/lib/python3.10/site-packages/twisted/python/context.py:82:callWithContext\n/opt/venv/lib/python3.10/site-packages/ocs/ocs_agent.py:1074:_running_wrapper\n/opt/venv/lib/python3.10/site-packages/ocs/agents/influxdb_publisher_v2/agent.py:91:record\n/opt/venv/lib/python3.10/site-packages/ocs/agents/influxdb_publisher_v2/drivers.py:67:__init__\n/opt/venv/lib/python3.10/site-packages/influxdb_client/client/bucket_api.py:101:find_bucket_by_name\n/opt/venv/lib/python3.10/site-packages/influxdb_client/service/buckets_service.py:558:get_buckets\n/opt/venv/lib/python3.10/site-packages/influxdb_client/service/buckets_service.py:586:get_buckets_with_http_info\n/opt/venv/lib/python3.10/site-packages/influxdb_client/_sync/api_client.py:343:call_api\n/opt/venv/lib/python3.10/site-packages/influxdb_client/_sync/api_client.py:173:__call_api\n/opt/venv/lib/python3.10/site-packages/influxdb_client/_sync/api_client.py:365:request\n/opt/venv/lib/python3.10/site-packages/influxdb_client/_sync/rest.py:268:GET\n/opt/venv/lib/python3.10/site-packages/influxdb_client/_sync/rest.py:261:request\n]', 'log_time': 1774557755.7741287}: "'Content-Type'"
2026-03-26T20:42:35+0000 record:0 Status is now "done".
We should catch this and log an appropriate message.
Line numbers are relevant to this commit: https://github.com/simonsobs/ocs/commit/b7fddf15dfbe2b39167089f9da1339bd8bb051a4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in agents/influxdb_publisher_v2/agent.py at record and follow the driver initialization in agents/influxdb_publisher_v2/drivers.py, where the stack trace reaches InfluxDB bucket lookup. Reproduce the invalid-token case and inspect how ApiException is handled. Done means the agent logs an appropriate message instead of crashing on the unauthorized response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100