Skip to content

fix(api): remove invalid joinedload on Incident.alerts property#6518

Open
hermes18974-jpg wants to merge 1 commit into
keephq:mainfrom
hermes18974-jpg:fix-6507-joinedload-alerts
Open

fix(api): remove invalid joinedload on Incident.alerts property#6518
hermes18974-jpg wants to merge 1 commit into
keephq:mainfrom
hermes18974-jpg:fix-6507-joinedload-alerts

Conversation

@hermes18974-jpg
Copy link
Copy Markdown

Summary

confirm_predicted_incident_by_id() used joinedload(Incident.alerts), but alerts is a Python @property backed by a _alerts PrivateAttr, not an ORM relationship.

SQLModel/SQLAlchemy raised:

Expected ORM mapped instance attribute, got: <property object>

This caused POST /v2/incidents/{id}/confirm to return 500 when confirming predicted incidents that have associated alerts.

Changes

  • Removed the invalid .options(joinedload(Incident.alerts)) call from confirm_predicted_incident_by_id() in keep/api/core/db.py.
  • The alerts property already reads from _alerts which is populated elsewhere; eager-loading it via SQL is unnecessary and incorrect.

Fixes

Fixes #6507

Checklist

  • Bug fix (non-breaking)
  • No new dependencies
  • Minimal change — one line removed

 used ,
but  is a Python @Property backed by a PrivateAttr, not an ORM
relationship. SQLModel/SQLAlchemy raised:

  Expected ORM mapped instance attribute, got: <property object>

This caused POST /v2/incidents/{id}/confirm to return 500 when confirming
predicted incidents that have associated alerts.

Removing the eager-load option lets the property resolve naturally
from the already-loaded incident instance.

Fixes keephq#6507
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. API API related issues Bug Something isn't working labels May 20, 2026
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 20, 2026

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API API related issues Bug Something isn't working size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[🐛 Bug]: POST /v2/incidents/<uuid>/confirm returns 500 when confirming a predicted incident

2 participants