-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Summary
Few Beamline documents trigger Pydantic validation errors when loaded:
service_accounts.operator - Field required
endstations.0.service_accounts.<fields> - Field required
This blocks workflows (e.g. detector onboarding, data security sync) for affected beamlines.
Root Cause
In ServiceAccounts the fields are declared as:
ioc: Optional[str]
workflow: Optional[str]
bluesky: Optional[str]
epics_services: Optional[str]
operator: Optional[str]In Pydantic v2, Optional[T] without a default still makes the field required: the key must be present, though its value may be None. Documents edited directly in MongoDB have:
- Missing keys (e.g.
operatorabsent entirely) - Empty
{}for an endstation’sservice_accounts
This produces “Field required” errors (missing keys), not “None disallowed.”
Current State
- Currently updating values directly in MongoDB (dev and prod) (no API support yet).
- Potential absence of Validation rules in MongoDB (need to verify)
Short-Term Fix
- To update the fields in both DEV and PROD – need access to ssh into hosts: mongo1 (MongoDB), api-dev1 (dev API), api4 (prod API), mongodev.
Recommended Model Change
- Add a PATCH endpoint which is admin locked to be able to make changes and enforce that all required service_accounts fields are present (reject partial or empty dicts).
- Add a MongoDB validation rule so new entries always have the required fields and stay consistent.
Metadata
Metadata
Assignees
Labels
No labels