While transforming my scripts to deal with v2.0 I messed up the gui address path to include a couple of quotes. That is my config read similar to this:
<gui enabled="true" tls="false" sendBasicAuthPrompt="false">
<address>'/tmp/st.sock'</address>
<metricsWithoutAuth>false</metricsWithoutAuth>
<apikey>secret</apikey>
<theme>default</theme>
</gui>
This leads to this error message:
Failed to start API (error="listen tcp: address '/tmp/st.sock': missing port in address" log.pkg=syncthing)
My incorrect assumption was that the major version bump to v2.0 had led to a regression in syncthing, breaking the API over unix domain socket. I still find that to be a reasonable interpretation of the quoted error message.
I took me quite a session before figuring out the mistake was mine. First with a failed attempt at adding a unix domain socket test case to lib/api/api_test.go. Then with a very confusing git-bisect experience. Where I started to question my sanity, when neither the latest v1 release nor any older version which actually still builds managed to serve as the known good commit.
Once I actually realized the added quotes, it of course became obvious. Yet an error message can be more helpful in identifying the cause of the error than this one currently is. In my opinion, a better message would be:
Failed to start API (error="invalid address: '\'/tmp/st.sock\''" log.pkg=syncthing)
Note the added quotes and the escaping of original quotes.
I don’t object to retaining the existing error message in cases when an actual tcp configuration has been detected.
One perspective is that (GUIConfiguration) Network() does insufficient validation. Thus an error leaks from a later method called with incorrect assumptions, one which arguable should never have been called at all.
In my opinion the function signature ought to be updated from returning string to (string, error), accompanied with something like matching a bunch of regexps of valid address formats.
Golang isn’t my primary language, but I could have a go at landing this change, if it is at all welcome? Preferably there ought to be an added test case too, but I obviously didn’t fully understand the existing tests. Are actual connections made at all, or is the transport mocked away?