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 ?

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