Skip to content

Feat: support HTTPS URLs in the -c/--config flag - #950

Open
Omar1H1 wants to merge 1 commit into
warpstreamlabs:mainfrom
Omar1H1:feature/support_remote_configuration
Open

Feat: support HTTPS URLs in the -c/--config flag#950
Omar1H1 wants to merge 1 commit into
warpstreamlabs:mainfrom
Omar1H1:feature/support_remote_configuration

Conversation

@Omar1H1

@Omar1H1 Omar1H1 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements #939, allows -c/--config to accept an https:// URL
in addition to a local file path.

Changes

  • internal/config/reader.go — URL detection, fetch logic, watcher guard
  • internal/config/lint.go — URL support for ReadYAMLFileLinted
  • internal/cli/run.go--config-header flag definition
  • internal/cli/common/reader.go — watcher fatal error, headers wired into NewReader
  • internal/config/reader_test.go — added unit tests for fetchRemoteConfig and remote reader behaviour
  • internal/config/lint_test.go — new file, unit tests for ReadYAMLFileLinted with remote URLs

Behaviour

  • https:// prefix → remote fetch before config parsing
  • Everything else → unchanged file path behaviour
  • Non-2xx response → exits with status code in error message
  • --watcher + URL → exits with fatal error immediately
  • env var interpolation (${FOO:default}) still works after fetch
  • --config-header "Name: Value" (repeatable) for auth headers

Testing

  • bento -c url → stream starts correctly
  • bento -c url echo → prints normalised config
  • bento -c url streams → streams mode works
  • bento lint url → lints remote config
  • bento -c url --config-header "K: V" → auth header forwarded
  • bento -c url --config-header "bad" → clear format error
  • bento -c url-returning-404 → clear 404 error
  • bento -c url-returning-401 → clear 401 error
  • bento -c url --watcher → fatal error on startup
  • bento -c path/to/file.yaml → unchanged behaviour

Known limitations

  • Only https:// URLs are supported. plain http:// falls back to
    file path behaviour.

  • bento lint <url> works for public endpoints but does not support
    --config-header. ReadYAMLFileLinted has no access to CLI flags
    at that call site. Can be addressed in a follow-up.

    Open question

As noted in #939. happy to move to a dedicated --config-url flag if that is preferred over extending -c.

Allow Bento to fetch its configuration from an HTTPS URL at startup
in addition to a local file path. Adds an optional --config-header
flag (repeatable) for authenticated endpoints.

- URL detection in config loading layer (reader.go, lint.go)
- --watcher + HTTPS URL exits with a clear fatal error
- env var interpolation works after fetch
- bento lint supports HTTPS URLs as positional args
- Unit tests for fetchRemoteConfig and ReadYAMLFileLinted

Closes warpstreamlabs#939

@jem-davies jem-davies left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would need to document the new feature by changing the documentation strings for the -c / --config flag as well

Comment thread internal/config/lint.go
var lints []docs.Lint
var err error

if strings.HasPrefix(path, "https://") {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if strings.HasPrefix(path, "https://") {
parsedPath, err := url.Parse(path)
if err != nil {
...
}
if parsedPath.Scheme == "https" || parsedPath.Scheme == "http" {
...
}

Could use url.Parse here - if the provided path is a relative filepath ./config.yaml scheme should be empty string, you could also have a scheme file too - file:///Users/.../config.yaml

Comment thread internal/config/reader.go
}

func fetchRemoteConfig(url string, headers []string) ([]byte, error) {
req, err := http.NewRequest(http.MethodGet, url, nil)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could use a http.NewRequestWithContext() and pass a context with a short deadline.

Comment thread internal/config/reader.go
req.Header.Add(strings.TrimSpace(name), strings.TrimSpace(value))
}

client := &http.Client{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we might want to expose some more options for the client - such it could work with TLS certificates that are signed with private CA's etc.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hello @jem-davies
Thanks for the feedback, i'm just wondering should this reuse existing CLI flags or
env vars, or would you prefer dedicated flags like --config-tls-ca-file ?

@jem-davies

Copy link
Copy Markdown
Collaborator

Hi @Omar1H1

Me and @gregfurman have just been discussing this PR.

I am in the position that the config options for this new http client could be handled similarly to the http root level config - perhaps with a field http_client.

That it would be possible to provide this to Bento in a ./resources.yaml - such it could then subsequently fetch a stream config.

Added multiple CLI flags I think wouldn't be the way to go, there is precedent for the majority of config be provided via YAML files.

@gregfurman - perhaps was more critical that there is other ways to handle this situation i.e. sidecar / init containers, posting into bento running streams_mode, that we discussed on discord before. That adding this feature is moving the complexity from already existing solutions into Bento.

Also Greg mentioned that we could perhaps have the concept of 'hooks', such there would be an 'on_init' hook that would evoke some user-defined logic at start-up and there we could fetch the config.

@Omar1H1

Omar1H1 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

Hi @jem-davies thanks for the detailed direction.

I think what you have suggested is the right way to go. If I may add, maybe naming it remote_config or config_source instead of http_client to make the intent clearer.

I totally understand @gregfurman concerns, the alternatives he mentioned are valid. That said, I do think there's value in making this a first-class feature rather than pushing it to the infrastructure layer. Happy to implement this direction if there's alignment. If not, that's completely fine and I can close the PR for now. maybe a clearer need will come up in the future.

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