Skip to content

fix(reflect): accept a top-level array of delta operations - #3829

Open
ebarkhordar wants to merge 1 commit into
vectorize-io:mainfrom
ebarkhordar:fix/3820-delta-ops-toplevel-array
Open

fix(reflect): accept a top-level array of delta operations#3829
ebarkhordar wants to merge 1 commit into
vectorize-io:mainfrom
ebarkhordar:fix/3820-delta-ops-toplevel-array

Conversation

@ebarkhordar

Copy link
Copy Markdown
Contributor

parse_delta_operation_list requires the parsed JSON to be a dict carrying an operations key. When a model emits the operations as a bare top-level array, which is legal JSON and structurally complete, the guard rejects the whole payload with delta payload must be an object with an operations array, so _validate_operations_list and _finalize_operations never see ops that are individually valid. At llm_temperature_consolidation (0.0) the output is deterministic for a given window, so the refresh then fails identically on every retry.

#3424 decoupled the transport cap and fixed the truncation case. This is the other malformation that shared that error message: here the JSON is complete, only its top-level container differs.

Fix

Normalize a top-level list to {"operations": <list>} before the dict check, then fall through to the existing path. Per-op validation, invalid-op skipping and the all-ops-invalid error are unchanged, because the normalized payload reaches exactly the same code. The normalization only fires on a value that previously took the continue branch, so no payload that parses today changes behaviour.

Verification

Run in a clean container at 8c01b89:

  • the three new tests in tests/test_delta_operation_parse.py fail on main with the ValueError above and pass on the branch
  • across the ten test files that cover delta_ops, passes go from 228 to 231, the difference being these three; 80 errors appear identically on both arms and are a missing pg0 extra in the container, not a regression
  • ruff check, ruff format --check and ty check hindsight_api at the locked 0.14.9 and 0.0.8, with ty reporting the same 211 diagnostics on both arms
  • install, compileall and the import smoke on 3.11 and 3.14, the ends of the build-api-python-versions matrix

What this does not cover: nothing here drives a live provider or a real refresh, so the end-to-end wedge stays your observation rather than something I reproduced. I also left the prose-wrapped case alone, since _extract_balanced_json_object still searches for a { and an array wrapped in commentary is unchanged.

One note on the sample payload in the report: its op carries the v1 block field, which AppendBlockOp does not define, so that exact snippet still raises, now as DeltaAllOpsInvalidError from per-op validation instead of on the top-level type. test_parse_delta_operation_list_rejects_v1_block_payloads pins that shape as invalid on purpose, so the tests here use text.

Fixes #3820

A model that emits the operations as a bare top-level JSON array had the whole payload
rejected before per-op validation ran. Normalize a top-level list to {"operations": [...]}
and fall through to the existing validation path.

Fixes vectorize-io#3820
@strix-security

strix-security Bot commented Aug 27, 2026

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for bbdbeba.


Reviewed by Strix
Re-run review · Configure security review settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant