Skip to content

feat(envconfig): add extension support - #1736

Merged
johanngan merged 5 commits into
mainfrom
johanngan/envconfig-extensions
Nov 5, 2026
Merged

johanngan merged 5 commits into
mainfrom
johanngan/envconfig-extensions

Conversation

@johanngan

@johanngan johanngan commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What was changed

Add support for envconfig extensions. These allow separate packages to extend envconfig with their own TOML keys and environment variables by implementing the ClientConfigExtension trait. An extension operates on a config profile as input and outputs a plugin to be attached to the client created from envconfig output.

A TOML file with an extension looks as follows:

[profile.default.ext.my_extension]
some_field = "value"

Core: config profiles expose the raw TOML tables under profile..ext, keyed by extension name.

Rust SDK: behind the experimental feature, an envconfig consumer specifies a list of extensions to use when loading client options via ClientOptions::load_from_config_with_extensions(). Returned plugins are registered on the returned ClientOptions. For now, extensions are not supported in other contexts.

C bridge: the profile JSON includes ext, so core-based SDKs can implement extensions on top of it.

Why?

It's useful for external modules to be able to extend the envconfig format without needing to modify the envconfig module itself. The first use-case for this will be integrating with AWS Secrets Manager to specify client secrets via Secrets Manager ID.

Since envconfig in Python, .NET, and Ruby are based on the Rust core through the C bridge, this change is a necessary prerequisite for implementing envconfig extensions in those languages. Those changes won't be able to proceed without a submodule update.

Also see the Go implementation in temporalio/sdk-go#2771

Checklist

  1. How was this tested:
  • Added new unit tests.
  • Manual end-to-end check (run by Claude): a small standalone crate loaded a real temporal.toml (via TEMPORAL_CONFIG_FILE) with an [profile.default.ext.e2e] table, using real process env vars (TEMPORAL_NAMESPACE, TEMPORAL_EXT_E2E_SUFFIX). An extension passed to ClientOptions::load_from_config_with_extensions read its TOML table and env var and returned a plugin. The program confirmed that the extension saw the env-overridden profile, and that the returned options had the expected namespace and target and exactly one plugin carrying the expected values.
  1. Any docs updates needed?
    The associated in-repo docs are updated. I don't think we need other public docs for now, as right now this is primarily just an implementation detail for the Lambda worker integration with Secrets Manager.

Add support for envconfig extensions. These allow separate packages to
extend envconfig with their own TOML keys and environment variables by
implementing the ClientConfigExtension trait. An extension operates on
a config profile as input and outputs a plugin to be attached to the
client created from envconfig output.

A TOML file with an extension looks as follows:

```
[profile.default.ext.my_extension]
some_field = "value"
```

Core: config profiles expose the raw TOML tables under
profile.<name>.ext, keyed by extension name.

Rust SDK: behind the experimental feature, an envconfig consumer
specifies a list of extensions to use when loading client options via
ClientOptions::load_from_config_with_extensions(). Returned plugins are
registered on the returned ClientOptions. For now, extensions are not
supported in other contexts.

C bridge: the profile JSON includes ext, so core-based SDKs can
implement extensions on top of it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@johanngan
johanngan force-pushed the johanngan/envconfig-extensions branch from a9626f6 to 3fd4b5b Compare November 3, 2026 21:24
@johanngan

Copy link
Copy Markdown
Contributor Author

(Slight update: decided to add a ClientConfigEnv struct for accessing the env in ClientConfigExtensionRequest instead of a bare HashMap, since otherwise the HashMap is exposed in the public API of ClientOptions::load_from_config_with_extensions(), which isn't really idiomatic in Rust. This is the only language implementation that had this problem)

Comment thread crates/client/src/envconfig.rs Resolved
It's long and probably unnecessary.
@johanngan
johanngan requested a review from THardy98 November 4, 2026 17:01

@THardy98 THardy98 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM.

One requested change:

Could we explicitly document that callers should pass these returned options to Client::connect? The existing envconfig quick-start uses Connection::connect followed by Client::new, which skips connection plugin hooks.

This is a gotcha that needs to be explicitly documented
@johanngan

johanngan commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

One requested change:

Could we explicitly document that callers should pass these returned options to Client::connect? The existing envconfig quick-start uses Connection::connect followed by Client::new, which skips connection plugin hooks.

Ah, good catch. I added a note to the file-level docstring/snippet and also the docstring for load_from_config_with_extensions

@johanngan
johanngan enabled auto-merge (squash) November 5, 2026 16:42
@johanngan
johanngan merged commit b9016f4 into main Nov 5, 2026
41 of 44 checks passed
@johanngan
johanngan deleted the johanngan/envconfig-extensions branch November 5, 2026 18:34
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.

2 participants