Skip to content

Commit 81a95eb

Browse files
committed
fix(bay): eagerly capture release ORM attributes before session expiry
Load release.id and release.stage.value into local variables before calling exec_browser_batch, which triggers ensure_running and may rollback/commit the shared DB session, expiring all attached ORM objects and causing MissingGreenlet errors on later access.
1 parent d2cc8bc commit 81a95eb

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

pkgs/bay/app/api/v1/capabilities.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,12 @@ async def run_browser_skill(
597597
if release is None:
598598
raise NotFoundError(f"No active release found for skill_key: {skill_key}")
599599

600+
# Eagerly capture ORM scalar attributes *before* calling exec_browser_batch,
601+
# which internally calls ensure_running → rollback/commit and expires all
602+
# objects attached to the shared DB session (MissingGreenlet otherwise).
603+
release_id = release.id
604+
release_stage_value = release.stage.value
605+
600606
candidate = await skill_svc.get_candidate(owner=owner, candidate_id=release.candidate_id)
601607
payload = await skill_svc.get_payload_by_ref(
602608
owner=owner,
@@ -652,8 +658,8 @@ async def run_browser_skill(
652658
merged_tags = skill_svc.merge_tags(
653659
request.tags,
654660
f"skill:{skill_key}",
655-
f"release:{release.id}",
656-
f"stage:{release.stage.value}",
661+
f"release:{release_id}",
662+
f"stage:{release_stage_value}",
657663
)
658664
current_session = await sandbox_mgr.get_current_session(sandbox)
659665
execution = await skill_svc.create_execution(
@@ -675,7 +681,7 @@ async def run_browser_skill(
675681

676682
return BrowserSkillRunResponse(
677683
skill_key=skill_key,
678-
release_id=release.id,
684+
release_id=release_id,
679685
execution_id=execution.id,
680686
execution_time_ms=execution_time_ms,
681687
trace_ref=trace_ref,

pkgs/bay/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)