zap: an error the wire has no word for must not read as success

ErrorUnspecified is the zero value and carries "the call succeeded" — a reply
holding it is read as a good answer and its fields are trusted. The only other
codes name a closed database and a missing key, so every other failure had
nowhere to go and was reported as the zero. A caller then took a zero-valued
block as a real one.

ErrorInternal gives those failures a word. Appending is safe in both
directions: errorFromZAP's default arm turns an unknown code into an error, so
a reader that predates this still sees a failure rather than a success.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-08-15 22:40:11 -07:00
co-authored by Hanzo Dev
parent 31058e5e41
commit ecb87b5eb5
+6
View File
@@ -20,11 +20,17 @@ const (
// Error represents VM errors
type Error uint8
// The zero value carries "the call succeeded" — a reply whose Err is
// ErrorUnspecified is read as a good answer and its fields are trusted. Every
// other value names a failure, so a failure the vocabulary has no word for
// must reach the caller as ErrorInternal. Mapping it onto the zero instead
// hands back a zero-valued block under the name of success.
const (
ErrorUnspecified Error = iota
ErrorClosed
ErrorNotFound
ErrorStateSyncNotImplemented
ErrorInternal
)
// InitializeRequest contains initialization parameters.