Fail closed on historical anchor hydration throws
This commit is contained in:
parent
cd3fb5b14f
commit
fd48f26162
2 changed files with 19 additions and 2 deletions
|
|
@ -14808,7 +14808,9 @@ function _hydrateIdLinkedHistoricalToolScenes(messages, options){
|
|||
let hydrated=0;
|
||||
const hydrateTurn=(turnEnd)=>{
|
||||
if(turnStart<0||turnEnd<=turnStart+1) return;
|
||||
const hydratedTurn=_idLinkedHistoricalTurnScene(list,turnStart,turnEnd,options);
|
||||
let hydratedTurn;
|
||||
try{hydratedTurn=_idLinkedHistoricalTurnScene(list,turnStart,turnEnd,options);}
|
||||
catch(e){return;}
|
||||
if(!hydratedTurn) return;
|
||||
const owner=list[hydratedTurn.ownerIndex];
|
||||
try{owner._anchor_activity_scene=hydratedTurn.scene;}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ function extractFunc(name){
|
|||
""".strip()
|
||||
|
||||
|
||||
def _run_hydration(messages: list[dict], *, repeat: bool = False) -> dict:
|
||||
def _run_hydration(messages: list[dict], *, repeat: bool = False, throw_helper: bool = False) -> dict:
|
||||
assert NODE, "node is required for Anchor hydration behavior tests"
|
||||
script = f"""
|
||||
const fs = require('fs');
|
||||
|
|
@ -89,6 +89,13 @@ for(const name of [
|
|||
vm.runInContext(extractFunc(name), sandbox, {{filename:'ui.js:' + name}});
|
||||
}}
|
||||
|
||||
if({str(throw_helper).lower()}){{
|
||||
vm.runInContext(
|
||||
"_toolArgsSnapshot = function(){{ throw new Error('synthetic event build failure'); }}",
|
||||
sandbox
|
||||
);
|
||||
}}
|
||||
|
||||
const messages = {json.dumps(messages)};
|
||||
sandbox.messages = messages;
|
||||
const first = vm.runInContext(
|
||||
|
|
@ -294,6 +301,14 @@ def test_ambiguous_or_richer_historical_tool_shapes_keep_legacy_ownership(messag
|
|||
assert data["owners"] == []
|
||||
|
||||
|
||||
@pytest.mark.skipif(NODE is None, reason="node is required for Anchor hydration tests")
|
||||
def test_event_building_helper_exceptions_keep_legacy_ownership():
|
||||
data = _run_hydration(_linked_turn(), throw_helper=True)
|
||||
|
||||
assert data["first"] == 0
|
||||
assert data["owners"] == []
|
||||
|
||||
|
||||
@pytest.mark.skipif(NODE is None, reason="node is required for Anchor hydration tests")
|
||||
def test_reused_ids_in_adjacent_complete_turns_remain_turn_scoped():
|
||||
data = _run_hydration(_linked_turn("call-reused") + _linked_turn("call-reused"))
|
||||
|
|
|
|||
Loading…
Reference in a new issue