Description
The generic v2 Model API search for GroupLocation returns HTTP 500 whenever it materializes full GroupLocation entities. The HTTP body is the generic {"Message":"An error has occurred."}, but the ExceptionLog shows serialization fails because a lazy-loaded navigation collection (GroupLocationScheduleConfigs) is accessed after the EF ObjectContext has already been disposed.
This appears to be framework-level — a stock entity and stock navigation property, no custom code — and reproduces with any GroupLocation row. Other entities' search endpoints return normally; GroupLocation is the one that defer-loads a navigation collection during serialization.
A client-side workaround exists (projecting scalar fields via select), so this isn't urgent. Flagging it because the default search (no select) is unusable for GroupLocation, and the same failure mode could affect any entity whose navigation collection lazy-loads during serialization.
The Reproduced the problem on a fresh install or on the demo site checkbox below about the fresh installation is not fresh as of today, but the install was done from scratch.
Actual Behavior
HTTP 500, body {"Message":"An error has occurred."}. The ExceptionLog records two chained exceptions:
Newtonsoft.Json.JsonSerializationException:
Error getting value from 'GroupLocationScheduleConfigs' on
'System.Data.Entity.DynamicProxies.GroupLocation_<proxy>'.
at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)
at ...JsonSerializerInternalWriter.SerializeObject(...)
at ...JsonSerializerInternalWriter.SerializeList(...)
Inner — System.ObjectDisposedException:
The ObjectContext instance has been disposed and can no longer be used for
operations that require a connection.
at System.Data.Entity.Core.Objects.ObjectContext.get_Connection()
at ...EntityCollection`1.Load(...)
at ...RelatedEnd.DeferredLoad()
at ...LazyLoadBehavior.LoadProperty[TItem](...)
Likely cause: search returns EF dynamic-proxy entities with lazy loading enabled; during serialization Newtonsoft reads GroupLocationScheduleConfigs, triggering a deferred load after the request's DbContext has been disposed.
Workaround (returns 200): project scalar fields only —
{ "select": "new(Id, GroupId, LocationId, GroupLocationTypeValueId)", "limit": 50 }
Possible fix: disable lazy loading / proxy creation before serializing search results in the generic model controller (or eager-load + detach the graph).
Expected Behavior
HTTP 200 with the standard envelope, identical to every other entity's v2 model search:
{ "count": 1, "items": [ /* GroupLocation objects */ ] }
Steps to Reproduce
- Grant a REST API key's role read access to the GroupLocations v2 controller's
search action (or use an admin session on the demo site).
POST the search with no projection:
curl -s -o /dev/null -w "%{http_code}\n" \
-X POST "https://<your-rock>/api/v2/models/grouplocations/search" \
-H "Authorization-Token: <api-key>" \
-H "Content-Type: application/json" \
-d '{ "limit": 1 }'
- Observe HTTP 500. An empty body
{} also reproduces. GetItem / GetAttributeValues on the same controller are unaffected.
Reproduces: 100%
Issue Confirmation
Rock Version
Rock McKinley 18.2 (18.2.4)
Client Culture Setting
en-US
Description
The generic v2 Model API
searchfor GroupLocation returns HTTP 500 whenever it materializes fullGroupLocationentities. The HTTP body is the generic{"Message":"An error has occurred."}, but theExceptionLogshows serialization fails because a lazy-loaded navigation collection (GroupLocationScheduleConfigs) is accessed after the EFObjectContexthas already been disposed.This appears to be framework-level — a stock entity and stock navigation property, no custom code — and reproduces with any
GroupLocationrow. Other entities'searchendpoints return normally;GroupLocationis the one that defer-loads a navigation collection during serialization.A client-side workaround exists (projecting scalar fields via
select), so this isn't urgent. Flagging it because the defaultsearch(noselect) is unusable forGroupLocation, and the same failure mode could affect any entity whose navigation collection lazy-loads during serialization.The
Reproduced the problem on a fresh install or on the demo sitecheckbox below about the fresh installation is not fresh as of today, but the install was done from scratch.Actual Behavior
HTTP 500, body
{"Message":"An error has occurred."}. TheExceptionLogrecords two chained exceptions:Likely cause:
searchreturns EF dynamic-proxy entities with lazy loading enabled; during serialization Newtonsoft readsGroupLocationScheduleConfigs, triggering a deferred load after the request'sDbContexthas been disposed.Workaround (returns
200): project scalar fields only —{ "select": "new(Id, GroupId, LocationId, GroupLocationTypeValueId)", "limit": 50 }Possible fix: disable lazy loading / proxy creation before serializing
searchresults in the generic model controller (or eager-load + detach the graph).Expected Behavior
HTTP 200 with the standard envelope, identical to every other entity's v2 model
search:{ "count": 1, "items": [ /* GroupLocation objects */ ] }Steps to Reproduce
searchaction (or use anadminsession on the demo site).POSTthe search with no projection:{}also reproduces.GetItem/GetAttributeValueson the same controller are unaffected.Reproduces: 100%
Issue Confirmation
Rock Version
Rock McKinley 18.2 (18.2.4)
Client Culture Setting
en-US