Skip to content

DB Performance #132

Merged
hubert-marek merged 4 commits intomainfrom
fixes-kdd
Feb 11, 2026
Merged

DB Performance #132
hubert-marek merged 4 commits intomainfrom
fixes-kdd

Conversation

@hubert-marek
Copy link
Collaborator

No description provided.

@claude
Copy link

claude bot commented Feb 11, 2026

Code Review

Found 7 critical SyntaxError issues that will prevent the calendar service from loading.

Python 3 Exception Handling Syntax Errors

All 7 issues involve the same problem: parentheses were removed from except clauses that catch multiple exception types. In Python 3, this syntax is invalid.

The Problem:

  • Python 2 syntax: except ValueError, name: (catch ValueError and bind to variable 'name')
  • Python 3 removed this syntax entirely
  • Python 3 requires parentheses to catch multiple exceptions: except (ValueError, TypeError):

Impact: These are SyntaxErrors that occur at import time, which means the calendar service will completely fail to load.


Issues Found:

1. backend/src/services/calendar/api/methods.py:162

# Current (INVALID):
except ValueError, AttributeError:

# Should be:
except (ValueError, AttributeError):

dt = dt.replace(tzinfo=timezone.utc)
# Convert to milliseconds since epoch
return int(dt.timestamp() * 1000)
except ValueError, AttributeError:
pass
# Invalid format


2. backend/src/services/calendar/api/methods.py:329

# Current (INVALID):
except ValueError, TypeError:

# Should be:
except (ValueError, TypeError):

else:
try:
value = int(raw_value)
except ValueError, TypeError:
raise InvalidParameterError(name, f"{name} must be a valid integer")
if max_value is not None:


3. backend/src/services/calendar/api/methods.py:356

# Current (INVALID):
except ValueError, TypeError:

# Should be:
except (ValueError, TypeError):

return None
try:
return int(raw_value)
except ValueError, TypeError:
raise InvalidParameterError(name, f"{name} must be a valid integer")


4. backend/src/services/calendar/database/operations.py:2006

# Current (INVALID):
except ValueError, TypeError:

# Should be:
except (ValueError, TypeError):

else:
parsed_dt = parsed_dt.astimezone(tzinfo)
start_dt = parsed_dt
except ValueError, TypeError:
start_dt = now_local.replace(minute=0, second=0, microsecond=0) + timedelta(
hours=1
)


5. backend/src/services/calendar/database/operations.py:2573

# Current (INVALID):
except KeyError, ValueError:

# Should be:
except (KeyError, ValueError):

if time_zone:
try:
target_tz = ZoneInfo(time_zone)
except KeyError, ValueError:
# Invalid timezone - fall back to UTC
pass


6. backend/src/services/calendar/database/operations.py:2729

# Current (INVALID):
except KeyError, ValueError:

# Should be:
except (KeyError, ValueError):

try:
event_tz = ZoneInfo(event_tz_name)
start_dt = start_dt.replace(tzinfo=event_tz)
except KeyError, ValueError:
start_dt = start_dt.replace(tzinfo=dt_timezone.utc)
elif start_dt.tzinfo is None:
start_dt = start_dt.replace(tzinfo=dt_timezone.utc)


7. backend/src/services/calendar/database/operations.py:2742

# Current (INVALID):
except KeyError, ValueError:

# Should be:
except (KeyError, ValueError):

try:
end_tz = ZoneInfo(end_tz_name)
end_dt = end_dt.replace(tzinfo=end_tz)
except KeyError, ValueError:
end_dt = end_dt.replace(tzinfo=dt_timezone.utc)
elif end_dt.tzinfo is None:
end_dt = end_dt.replace(tzinfo=dt_timezone.utc)


Recommended Fix

Restore the parentheses in all 7 except clauses. This can be done with a find-and-replace:

  • In backend/src/services/calendar/api/methods.py: restore parentheses at lines 162, 329, and 356
  • In backend/src/services/calendar/database/operations.py: restore parentheses at lines 2006, 2573, 2729, and 2742

@hubert-marek hubert-marek merged commit f1e24a3 into main Feb 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant