Repository navigation
Description
Background
The Go SDK is in languages/golang. It encrypts and decrypts values in a Go program by calling the Rust engine, Stack Encrypt, through a WebAssembly guest. Generated code (*_stash.go, from stashgen) converts between a program's structs and the engine's values, with help from encrypt/gensupport.
Problem
A user reported, in passing, an error that said the input was "not an object" and named no field. We do not know what they ran. #1985 covers the engine's errors with this wording. It found that the Go SDK cannot reach any of them through its public API in normal use. This issue covers the places in the Go SDK itself where a user can see the same words, or close to them.
| Id | Where | When it is raised | What the user sees | Names the field |
|---|---|---|---|---|
| O2 | encrypt/gensupport/convert.go, valuesOf, called from Get in codec.go |
Decrypting a field of map type (map[string]V, Values, map[string]any) whose stored value opens to a list or a single value, for example a row written by another SDK or an older struct |
gensupport: field "x": cipherstash: malformed input: opened as []interface {}, not an object |
Yes |
| N1 | Engine json_query.rs, read_match, Reason::JsonInput |
A JSON Match query whose vars is a list, a number, JSON null, or a pointer to a nil map |
"... the input is not the object the JSON operator takes" | Probably, not checked |
| O3 | encrypt/query.go, about line 186 |
The guest's answer to se_query_term is not an object. This only happens on a bug or a version mismatch |
cipherstash: internal guest failure: se_query_term: came back as T, not an object |
No |
| O4 | encrypt/checker.go, about line 275 |
The guest's answer to se_targets or se_operators is malformed. Same cause |
operator N is T, not an object, wrapped |
No |
| O5 | auth/store.go, about line 465 |
The auth guest's result is not a map. Same cause | cipherstash: internal guest failure: the guest's result is not an object |
No |
How likely each is for a Go user, most likely first:
- O2. A user can cause it with data. The message names the field but shows a Go type (
[]interface {}), not what was stored, and does not say it happened during decrypt. - N1. Easy to cause by passing a list or
json.RawMessage("null")asvars. The words "not the object" are close to "not an object". - O3, O4, O5. Only on an internal bug or when the module and the guest come from different versions. They name no field, which matches the report. Their wording reads as a fault in the caller's input, not as an internal failure.
No test covers O2's message. No test covers O5.
Proposal
- O2: Say the operation and the found kind in words, and the Go type needed:
decrypt: field "x" opened as a list, and map[string]any needs an object. Add a test. - N1: Say what was found and what is needed, and name the operator:
match: vars is null; vars must be a JSON object. Check that the field name reaches the Go error, and add a test that asserts it. - O3, O4, O5: Keep them as internal errors, but name the guest export and say "the guest's answer", so the message does not read as bad input. If a version mismatch between the module and the guest can cause them, say that in the message and in the error's help.
- Ask anyone who reports a "not an object" error for the full message. Its first words show which row above it came from.
Relationship to other work
- stack-encrypt: "not an object" errors do not say what was found, or which field, row or operation #1985 covers the engine's
NotAnObjecterrors (E1 to E6).
Activity