diff --git a/src/DataAccess/src/SIL.DataAccess/MemoryUpdateBuilder.cs b/src/DataAccess/src/SIL.DataAccess/MemoryUpdateBuilder.cs index bbf6b5d9..4c537206 100644 --- a/src/DataAccess/src/SIL.DataAccess/MemoryUpdateBuilder.cs +++ b/src/DataAccess/src/SIL.DataAccess/MemoryUpdateBuilder.cs @@ -204,7 +204,23 @@ TField value (IEnumerable owners, PropertyInfo? prop, object? index) = GetFieldOwners(entity, filter, field); object[]? indices = index == null ? null : [index]; foreach (object owner in owners) - prop.SetValue(owner, value, indices); + { + if (owner is IDictionary dictionary) + { + if (index != null) + { + dictionary[index] = value; + } + else + { + throw new ArgumentException("Cannot set a field on a dictionary without an index.", nameof(field)); + } + } + else + { + prop.SetValue(owner, value, indices); + } + } } private static bool IsAnyMethod(MethodInfo mi) diff --git a/src/Serval/src/Serval.Translation/Services/TranslationPlatformServiceV1.cs b/src/Serval/src/Serval.Translation/Services/TranslationPlatformServiceV1.cs index 29023e6a..14f1444c 100644 --- a/src/Serval/src/Serval.Translation/Services/TranslationPlatformServiceV1.cs +++ b/src/Serval/src/Serval.Translation/Services/TranslationPlatformServiceV1.cs @@ -270,22 +270,14 @@ public override async Task UpdateBuildExecutionData( ServerCallContext context ) { - var build = await _builds.GetAsync(request.BuildId, cancellationToken: context.CancellationToken); - if (build == null) - { - throw new RpcException(new Status(StatusCode.NotFound, "Build not found.")); - } - - var updatedExecutionData = new Dictionary(build.ExecutionData); - - foreach (var entry in request.ExecutionData) - { - updatedExecutionData[entry.Key] = entry.Value; - } - await _builds.UpdateAsync( b => b.Id == request.BuildId, - u => u.Set(b => b.ExecutionData, updatedExecutionData), + u => + { + // initialize ExecutionData if it's null + foreach (KeyValuePair entry in request.ExecutionData) + u.Set(b => b.ExecutionData[entry.Key], entry.Value); + }, cancellationToken: context.CancellationToken );