Menu

1 / 5

Silent Failure #19: The Resolver Said SERVFAIL and My Classifier Said "No Such Host"

DEV Community: go·Renhua Wei·7 days ago
#rPoxG7PI
#devtogo#devto#dev#test#error
Long article (968 words) — no AI summary yet.
Reading 0:00
15s threshold

I was reading the error handling of a Go email verifier on a Saturday, and one function stopped me halfway down the file:

func parseBasicErr ( err error ) error { re := err . Error ( ) switch { case strings . Contains ( re , "timeout" ) : return ErrTimeout case strings . Contains ( re , "no such host" ) : return ErrNoSuchHost case strings . Contains ( re , "unavailable" ) : return ErrServerUnavailable } return LookupError { Message : re } }

Enter fullscreen mode

Exit fullscreen mode

Three substrings decide what happened to a DNS lookup. That is the whole classifier.

Then I hit the case that breaks it. A resolver returning SERVFAIL does not say "timeout" and does not say "no such host". It says this, verbatim:

lookup example.com on 127.0.0.11:53: server misbehaving

Enter fullscreen mode

Exit fullscreen mode

Zero hits. It falls straight through to the default, and the raw Go string becomes the value the rest of the library switches on.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.