Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

confmap Resolver URI Parsing doesn't work for valid yaml URIs #6306

Closed
cpheps opened this issue Oct 13, 2022 · 3 comments · Fixed by #6309
Closed

confmap Resolver URI Parsing doesn't work for valid yaml URIs #6306

cpheps opened this issue Oct 13, 2022 · 3 comments · Fixed by #6309
Labels
bug Something isn't working

Comments

@cpheps
Copy link
Contributor

cpheps commented Oct 13, 2022

Describe the bug
With the URI parsing changes from #6271 in the confgmap.Resolver valid yaml URIs no longer work.

Steps to reproduce
Take a valid yaml config string and use similar logic to below will result in an invalid URI error:

uriLocation := fmt.Sprintf("yaml:%s", yamlBytes)
provider := yamlprovider.New()
converter := expandconverter.New()
settings := service.ConfigProviderSettings{
	ResolverSettings: confmap.ResolverSettings{
		URIs:       []string{uriLocation},
		Providers:  map[string]confmap.Provider{provider.Scheme(): provider},
		Converters: []confmap.Converter{converter},
	},
}

service.NewConfigProvider(settings)

What did you expect to see?
No URI error

What did you see instead?
Error for invalid URI

What version did you use?
Version: v0.62.0

What config did you use?
any valid config

Environment
OS: macOS 12
Compiler(if manually compiled): go 1.19

Additional context
This seems to be an issue with the locationRegexp. I took a valid yaml URI from the yaml provider test here and plugged it into the regex and it fails to parse. I have this up on the go playground here.

Looks like it is due to the newlines in the yaml. If you remove the newlines the URI works or if you remove the $ from the locationRegexp it also works.

@cpheps cpheps added the bug Something isn't working label Oct 13, 2022
@cpheps
Copy link
Contributor Author

cpheps commented Oct 13, 2022

Investigating further it seems this regex will work for yaml URIs and other kinds.

^(?P<Scheme>[A-Za-z][A-Za-z0-9+.-]+):(?P<OpaqueValue>[\s\S]*)$

@bogdandrutu
Copy link
Member

found the issue, give me 2 mins

@cpheps
Copy link
Contributor Author

cpheps commented Oct 13, 2022

Fixed by #6309

@cpheps cpheps closed this as completed Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants