spf: err is not not nil if no error occurs (CheckHost)

6 views
Skip to first unread message

Christian Schneider

unread,
Apr 30, 2021, 8:06:14 PM4/30/21
to chas...@googlegroups.com
Hey,
I run in an issue with your spf library. I expected err to be nil if no
error happens. The docs does not say anything about it.

Code:
// should work
ip := net.ParseIP("138.201.174.101")
r, err := spf.CheckHost(ip, "androidloves.me")
fmt.Println("result", r, "err", err)

// should not work
ip = net.ParseIP("62.180.228.1")
r, err = spf.CheckHost(ip, "androidloves.me")
fmt.Println("result", r, "err", err)


Output:
result pass err matched 'mx'
result fail err matched 'all'


The results are right, but err is not empty if no error occurs. Am I
doing something wrong or whats the problem here?
It's not what I was expecting/conforms to the Go standard.

I'm also looking forward to the next version with the context support.
Do you know when it will be released?

Thanks for your effort.

kmille

Alberto Bertogli

unread,
Apr 30, 2021, 8:39:23 PM4/30/21
to Christian Schneider, chas...@googlegroups.com
On Thu, Apr 29, 2021 at 10:31:40AM +0200, Christian Schneider wrote:
>Hey,
>I run in an issue with your spf library. I expected err to be nil if
>no error happens. The docs does not say anything about it.
>
>Code:
>// should work
>ip := net.ParseIP("138.201.174.101")
>r, err := spf.CheckHost(ip, "androidloves.me")
>fmt.Println("result", r, "err", err)
>
>// should not work
>ip = net.ParseIP("62.180.228.1")
>r, err = spf.CheckHost(ip, "androidloves.me")
>fmt.Println("result", r, "err", err)
>
>
>Output:
>result pass err matched 'mx'
>result fail err matched 'all'
>
>
>The results are right, but err is not empty if no error occurs. Am I
>doing something wrong or whats the problem here?
>It's not what I was expecting/conforms to the Go standard.

You're not doing anything wrong. I agree it's unexpected/surprising, but
I didn't realize it was not properly documented, thank you for reporting
this!

I understand the usage of error here is not ideomatic, but it was a
tradeoff with keeping the API easier to use, given how SPF check results
already require non-trivial handling (as you know, it isn't a yes/no
answer, etc.).

I've made the following patch to document this behaviour, can you take a
look and let me know if it clarifies things a bit? Also let me know
(privately if you prefer) if you want to change your attribution.

https://blitiri.com.ar/git/r/spf/c/d29dbf32234c1c430b7ad62d876117ca73bbdfec/


>I'm also looking forward to the next version with the context support.
>Do you know when it will be released?

Now is a good time, since those changes have been out for a while :)

Once I'm happy enough with this documentation change, I'll make a
release and will let you know.


>Thanks for your effort.

Thanks to you for reporting this!

Alberto

Alberto Bertogli

unread,
May 9, 2021, 7:59:01 AM5/9/21
to Christian Schneider, chas...@googlegroups.com
BTW, I've just released spf 1.2.0 with these changes, thanks!

Alberto

Christian Schneider

unread,
May 10, 2021, 12:23:54 PM5/10/21
to Alberto Bertogli, chas...@googlegroups.com
cool! I will take a look in the next few weeks!

kmille
Reply all
Reply to author
Forward
0 new messages