keripy icon indicating copy to clipboard operation
keripy copied to clipboard

agenting.streamMessengerFrom prefers HTTP urls (and ignores HTTPS if both are present)

Open tsterker opened this issue 7 months ago • 2 comments

Version

1.1, 1.2, main (all)

Environment

Python 3.12, Linux

Expected behavior

(Apologies in advanced for a potential lack of proper terminology or deep understanding.)

When multiple URLs are given, all should be used.

Actual behavior

When both http and https locations are passed to agenting.streamMessengerFrom, only the http location is used.

See below code excerpt, which will preferentially pick the http scheme over the https scheme.

https://github.com/WebOfTrust/keripy/blob/e4f879671a9eb96da0327c036acb75bcfc4f2124/src/keri/app/agenting.py#L1052-L1054

Ideally, there should be either:

  • Multiple messages created in case of multiple URLs (but this is probably a breaking change)
  • An exception thrown, in case no unambiguous choice is possible
  • A way to configure an explicit preference
  • ...?

Steps to reproduce

(Apologies for the lack of a proper reproducible example)

  • Call streamMessengerFrom with multiple URLs:
# ...
urls = {
  kering.Schemes.http: 'http://foo',
  kering.Schemes.https: 'https://bar',
}

messenger = streamMessengerFrom(hab, pre, urls, msg)
  • 💥 See the http scheme to be used.

tsterker avatar May 13 '25 15:05 tsterker

We should just change the default here to use HTTPS instead of HTTP

pfeairheller avatar May 20 '25 14:05 pfeairheller

We should just change the default here to use HTTPS instead of HTTP

This could be considered a breaking change.

Example:

  • An agent has a broken HTTPS URL and a working HTTP URL advertised
  • The current behavior uses the (working) HTTP URL
  • A switch to use the (broken) HTTPS URL instead would lead to (silent) failures.
  • And to my knowledge, there is currently also no (KLI) way to remove a URL, only to override it. This would mean the only way to remediate is to get the HTTPS URL working (or replace it with a working one)

tsterker avatar Jun 03 '25 07:06 tsterker