zonemaster-engine
zonemaster-engine copied to clipboard
Avoid dying when query is not in cache when using no network mode
Currently when running the engine in no network mode if the engine queries for something that is not is the cached data then engine will die. A better option would be to emit a critical message and stop the test.
I don't think I agree with what is being asked here. From what I understand, "no_network" mode is a profile parameter which is only relevant when used with pre-recorded data, so for example in unitary tests.
In Engine 4.7.0, this relates to this part of the code, which currently is a croak
.
https://github.com/zonemaster/zonemaster-engine/blob/8ae6f4bee8dc134256dbb3f15c473310035c3409/lib/Zonemaster/Engine/Nameserver.pm#L438-L442
In normal circonstances Engine will never output such message so a logging message doesn't seem of much use, unless the user specifically sets "no_network" to true in the profile. Moreover, these logging messages are invisible when running unitary tests (i.e. using either perl
or prove
). On the contrary, I would argue that having an explicit death message (containing the name, query type and name server) is very much useful when dealing with pre-recorded data (e.g. unitary tests).
The only improvement I could see would be to gracefully die (e.g. die Zonemaster::Engine::Exception->new( { message => $message }
) instead of the current croak
. But I could very well be missing the point.
@blacksponge, I am not sure what problem you want to solve. "no_network" is primarily used during development.