Skip to content

stack-encrypt: "not an object" errors do not say what was found, or which field, row or operation #1985

Done

Description

@coderdan

Background

Stack Encrypt is the Rust engine in packages/stack-encrypt. Its dynamic::record module encrypts and decrypts records described by a plan. A record is a map from field names to values, such as {"email": "a@example.com", "age": 34}. A plan says how each field is encrypted. The Go SDK calls this module through a WebAssembly guest, and Rust programs can call it directly.

When the engine is given a plan, a record to encrypt or a stored record to decrypt that has the wrong shape, it returns Reason::NotAnObject. Its message is "not an object where one is expected".

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. So this issue covers every place the engine raises this error.

The engine raises NotAnObject in six places, all in packages/stack-encrypt/src/dynamic/record.rs. Five of them name no field. None says which row of a batch failed, or what was found instead of an object. A repeated key inside a field and a value that failed while it was read are reported the same way, so the message can point to the wrong cause.

Id Where When it is raised What the user sees Names the field
E1 plan_refusal, about line 1657 The plan is not one frame, or its root is null, a list or a single value "record plan is malformed: not an object where one is expected" No
E2 spec_keys, about line 1689 A field's spec is a list, null or a single value. Also a spec that holds a repeated key The same text, with (field "age") Yes
E3 source_rows, about line 2227 The record to encrypt is a single value, null or passthrough, or an element of a batch is not a map "record source does not fit the plan: not an object where one is expected" No, and no row number
E4 split_refusal, about line 2244 The value fails while one of its fields is read (FrameWriteError::Source). split_source in source.rs drops the field name, and the value's own error is lost The same text as E3 No
E5 record_rows, about line 2597 An element of a stored batch is not a map "stored record does not fit the plan: not an object where one is expected" No, and no row number
E6 record_rows, about line 2601 The stored record is neither a map nor a list of maps The same text as E5 No

A seventh, related message: a plan field declared "type": "object" that opens to a value that is not a map is refused as field "x" is not an object (plan/error.rs, raised in record.rs about line 2527). It names the field but not what was found.

Who can reach these today:

  • Verified: a Rust caller of dynamic::record::{plan, plan_with, encrypt, encrypt_with, check_source, decrypt, decrypt_with, check_record} can reach all six. The likeliest mistakes are passing JSON text instead of frame bytes as the plan (E1), and passing None or a single value as the record (E3).
  • Verified: the Go SDK does not reach E1 to E6 through its public API in normal use. It always sends the plan as an object (internal/record/record.go, Plan.Wire). It always sends the records as a list of objects (encrypt/records.go, Seal). It always sends stored rows as a list of maps. The guest refuses bytes that are not a frame before the engine sees them, as "an input is not a value in the transport frame" (guest/src/ops.rs, checked_plaintext). E1 and E5 are reachable from Go test helpers only. This holds for the current tree and for rc.3, rc.5 and rc.7. Older versions were not checked.
  • Verified: the TypeScript addon does not call dynamic::record.

So the reported error probably did not come from these paths through the Go SDK. #1987 covers the Go SDK's own messages that contain "not an object".

Proposal

Every refusal of this kind should say what was found, where, and in which operation.

  1. E1: Split into two reasons. Bytes that are not a frame get their own reason ("the plan is not a frame"). A frame whose root is not an object says what it is: "the plan is a list, not an object of field specs".
  2. E2: Keep the field name and add what was found ("a list"). Give a repeated key inside a spec its own reason, RepeatedKey, not NotAnObject.
  3. E3: Name the row of the batch ("row 3") and what was found ("null", "a string", "a list"). Say that it happened during encrypt.
  4. E4: In split_source, keep the open field name for a FrameWriteError::Source error too. Report it as a new reason, for example SourceFailed, with the field name, and keep the value's error as the cause.
  5. E5 and E6: Name the row of the batch and what was found ("row 2 is a single value, not a map of fields"). Say that it happened during decrypt.
  6. Object fields: Add what was found: field "x" opened as a list, not an object.
  7. Tests: One test for each case, asserting the reason, the field, the row and the found kind. Today no test checks a row number for E3 or E5, and the source.rs test for E4 asserts field == None, so it holds the current behaviour in place.
  8. Bindings: Add any new reason codes to the Go SDK's error mapping and to the conformance corpus (record-declarations-v1, record-reads-v1), so Go reports them with the same detail.

Evidence

Activity

  1. added
    bug
    Rust
    on Nov 27, 2026
  2. changed the title [-]stack-encrypt: a record whose value fails inside a field is reported as "not an object", with no field named[/-] [+]stack-encrypt: "not an object" errors do not say what was found, or which field, row or operation[/+] on Nov 27, 2026
  3. self-assigned this
    on Nov 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

RustSDKbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions