-
-
Notifications
You must be signed in to change notification settings - Fork 1
API 500 on /api/v1/entities — PostgreSQL enum case mismatch between SQLAlchemy model and PyDAL queries #97
Copy link
Copy link
Open
Description
Bug
GET /api/v1/entities?entity_type=network returns 500:
psycopg2.errors.InvalidTextRepresentation: invalid input value for enum entitytype: "network"
Root Cause
apps/api/models/entity.py defines EntityType(enum.Enum) with uppercase member names and lowercase values:
class EntityType(enum.Enum):
NETWORK = "network"SQLAlchemy's create_all creates the PostgreSQL enum using member names (uppercase) by default:
CREATE TYPE entitytype AS ENUM ('DATACENTER','VPC','SUBNET','COMPUTE','NETWORK','USER','SECURITY_ISSUE');But PyDAL and the worker connector pass lowercase values ('network'), which PostgreSQL rejects because enum comparisons are case-sensitive.
Fix
Add values_callable to the SQLAlchemy Column definition so the PostgreSQL enum uses the lowercase .value instead of the uppercase .name:
entity_type = Column(
SQLEnum(EntityType, values_callable=lambda e: [x.value for x in e]),
nullable=False
)Impact
- AWS connector sync fails completely — no entities are created
- Dashboard shows 0 entities despite successful AWS credential verification
- Affects v3.1.5 (
3.1.5.1774490516-beta) API image
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels