fix: _default_env_id uses scalars().first() instead of scalar_one_or_none()

scalar_one_or_none() raises MultipleResultsFound when more than one environment
exists. Use scalars().first() to pick the lowest-ID environment as the default.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
root 2026-05-27 07:36:30 +00:00
parent a9ef13afa8
commit e0b898df8e

View file

@ -125,7 +125,7 @@ async def _get_env_or_404(db: AsyncSession, env_id: int) -> Environment:
async def _default_env_id(db: AsyncSession) -> int | None: async def _default_env_id(db: AsyncSession) -> int | None:
e = (await db.execute(select(Environment).order_by(Environment.id))).scalar_one_or_none() e = (await db.execute(select(Environment).order_by(Environment.id))).scalars().first()
return e.id if e else None return e.id if e else None