Skip to content

feat(core): expose registered schemes via OperatorRegistry::schemes#7908

Merged
Xuanwo merged 2 commits into
apache:mainfrom
chitralverma:feat/registry-schemes
Jul 13, 2026
Merged

feat(core): expose registered schemes via OperatorRegistry::schemes#7908
Xuanwo merged 2 commits into
apache:mainfrom
chitralverma:feat/registry-schemes

Conversation

@chitralverma

@chitralverma chitralverma commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #7904.

Rationale for this change

OperatorRegistry already stores every registered scheme in its internal factories: Mutex<HashMap<String, OperatorFactory>>, but there was no public way to read those keys back. For the global registry, that set is exactly what Operator::from_uri can construct, and it is otherwise unobservable at runtime (it is fully determined by the compiled-in services-* features).

Without it, a common mistake — a wrong dialect (s3a://, gs:// vs gcs://) or a missing services-* feature — yields a bare scheme is not registered error with no hint about which schemes are available.

What changes are included in this PR?

  • Add OperatorRegistry::schemes() -> HashSet<String>, a thin read over the existing factories map under the current lock.
  • Enrich the from_uri scheme is not registered error with an available context that lists the registered schemes (sorted), turning a bare error into an actionable hint.
  • Add unit tests covering the accessor and the enriched error, plus a doctest on schemes().

Output (py bindings)

>>> import opendal
>>> opendal.Operator("asd",)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
opendal.exceptions.Unsupported: Unsupported (permanent) at  => scheme is not registered

Context:
   scheme: asd
   available: azblob, azdls, cos, cosn, file, fs, gcs, ghac, http, https, ipmfs, memory, obs, oss, s3, webdav, webhdfs

Are there any user-facing changes?

Yes, additive only:

  • New public method OperatorRegistry::schemes().
  • The from_uri unsupported-scheme error now carries an additional available context field listing registered schemes. No existing field or error kind changes; not a breaking change.

AI Usage Statement

This PR was prepared with the assistance of an AI coding agent (OpenCode, using an Anthropic Claude model) for implementation and drafting. All changes were reviewed by a human before submission.

Add a public OperatorRegistry::schemes() accessor that returns the set
of registered schemes (HashSet<String>) as a thin read over the existing
factories map. For the global registry this is exactly the set that
Operator::from_uri can construct.

Enrich the from_uri 'scheme is not registered' error with an 'available'
context listing the registered schemes, so a wrong dialect or missing
services-* feature surfaces an actionable hint instead of a bare error.
@chitralverma chitralverma requested a review from Xuanwo as a code owner July 13, 2026 04:03
Copilot AI review requested due to automatic review settings July 13, 2026 04:03
@dosubot dosubot Bot added releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a public accessor on OperatorRegistry to expose which URI schemes are registered at runtime, and enriches unsupported-scheme errors from load()/from_uri with an “available schemes” hint to make misconfigurations (wrong dialect / missing services-* feature) easier to diagnose.

Changes:

  • Introduces OperatorRegistry::schemes() -> HashSet<String> (with doctest) to expose registered schemes.
  • Enriches the unsupported-scheme error context with a sorted list of available schemes.
  • Adds unit tests for the accessor and for the enriched error output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/core/src/types/operator/registry.rs Outdated
load() held the factories mutex while the ok_or_else closure called
schemes(), which re-locked the same non-reentrant mutex and deadlocked
on the unsupported-scheme path. Collect the available schemes from the
guard already held instead of re-locking.
@chitralverma chitralverma requested a review from erickguan July 13, 2026 04:43
@erickguan

Copy link
Copy Markdown
Member

The scheme availability is solid and thanks to bring PR this quick. I'll jump back to issues to clarify design a bit in details.

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 13, 2026
@Xuanwo Xuanwo merged commit 3180510 into apache:main Jul 13, 2026
169 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer releases-note/feat The PR implements a new feature or has a title that begins with "feat" size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

new feature: expose registered schemes from OperatorRegistry

4 participants