influxdata / influxdata/influxdb

Provide a way to check if an org/bucket exists.

Open
#21,134 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/2.x area/api
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

Proposal:
Provide methods for checking for the existence of a particular org or bucket by name.

Current behavior:
BucketsAPI.getBuckets({ orgId, name }) will throw if the bucket with the provided name is not found, rather than returning an empty array of buckets as expected.

Desired behavior:
To get back an empty array of buckets if no bucket with the provided name exists.

Alternatives considered:
The samples imply that the user should catch the exception and then proceed, but this is considered a bad pattern. Exceptions should not be used for code flow, they should be exceptional. In my case, it is very reasonable that a bucket doesn't yet exist with the provided name but I have no way (using this library) to first check to see if a particular bucket exists before trying to create it.

Use case:
Exceptions should not be used for flow control, but currently that appears to be the only way to check for bucket existence. This means if I run my script in a debugger and enable "break on exceptions", my code will break in a non-exceptional code path.

The fact that you get a possibly undefined array of buckets implies to me (the library user) that I should except to get back an empty array (or maybe undefined array) if the provided bucket doesn't exist, but this isn't the case.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the BucketsAPI.getBuckets({ orgId, name }) entry point described in the issue and trace how a missing bucket is handled. Check the surrounding API surface for an existing organization or bucket lookup method; done means a missing named bucket can be checked without an exception and returns the expected empty result.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.