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

[Bug]: Loading consul configuration from environment variables fails in 1.7.14.4 #359

Open
tdeangelis opened this issue Aug 22, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tdeangelis
Copy link

Describe the bug

In 1.7.14.4 when loading the the consul configuration from the environment variable CONSUL_HTTP_ADDR it does not parse the variable correctly when using a string based host name for the consul address.

In 1.7.14.3 the following example setting would parse properly as the host name and port:
CONSUL_HTTP_ADDR = consul:8500

In 1.7.14.4 this get's parsed out as:

  • Host is left default (127.0.0.1)
  • Path is set to 8500
  • Port is set to -1

This is caused by the Uri.TryCreate reading that string as:

  • Scheme is set to consul
  • AbsolutePath is set to 8500

Steps To Reproduce

  1. Set your CONSUL_HTTP_ADDR to a DNS named consul server with port (consul:8500)
  2. Set your CONSUL_HTTP_TOKEN to a valid token for that consul server
  3. New up the ConsulClient object using the default constructor.
  4. Fetch any items from the KV (await client.KV.List("anykey");)
  5. Notice Exception:
    Exception has occurred: CLR/System.Net.Http.HttpRequestException
    An exception of type 'System.Net.Http.HttpRequestException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'No connection could be made because the target machine actively refused it. (127.0.0.1:80)'
    Inner exceptions found, see $exception in variables window for more details.
    Innermost exception System.Net.Sockets.SocketException : No connection could be made because the target machine actively refused it.
    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
    at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
    at System.Net.Sockets.Socket.<g__WaitForConnectWithCancellation|285_0>d.MoveNext()
    at System.Net.Http.HttpConnectionPool.d__104.MoveNext()

Expected behavior

Legacy URI parsing behavior for environment variables should be maintained or this should be called out as a breaking change in this version.

Environment

  • OS: Windows
  • Consul Version: 1.19.1
  • consultdotnet Version 1.7.14.4

Logs

No response

Additional context

No response

@tdeangelis tdeangelis added the bug Something isn't working label Aug 22, 2024
@tdeangelis tdeangelis changed the title [Bug]: Loading consul configuration from environment fails in 1.7.14.4 [Bug]: Loading consul configuration from environment variables fails in 1.7.14.4 Aug 22, 2024
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

No branches or pull requests

1 participant