diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f07619..68d5cf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.9.4] - 2026-01-04 + +### Fixed + +- Fix SQLAlchemy async lazy loading error for new users in `/auth/sync` + - Initialize `user.roles = []` and `user.preferences` to avoid greenlet error + - Was causing "MissingGreenlet: greenlet_spawn has not been called" on new user creation + ## [1.9.3] - 2026-01-04 ### Fixed diff --git a/pyproject.toml b/pyproject.toml index f383d9d..94db214 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "core-api" -version = "1.9.3" +version = "1.9.4" description = "Core Code API - Infrastructure management and tools API" readme = "README.md" requires-python = ">=3.12" diff --git a/src/domains/auth/service.py b/src/domains/auth/service.py index f6fe454..2644488 100644 --- a/src/domains/auth/service.py +++ b/src/domains/auth/service.py @@ -130,11 +130,14 @@ class AuthService: avatar_url=token_info.picture, last_login=datetime.now(timezone.utc), ) + # Initialize relationships to avoid lazy loading issues in async + user.roles = [] self.session.add(user) await self.session.flush() # Get the user ID - # Create default preferences + # Create default preferences and attach to user preferences = UserPreferences(user_id=user.id) + user.preferences = preferences self.session.add(preferences) logger.info(f"Created new user: {token_info.email}")