Skip to content

Commit d5b2ce7

Browse files
KevinJumpclaude
andauthored
Fix silently discarded save failures in Language/DictionaryItem/Webhook serializers (#1040)
SaveItemAsync discarded the Attempt<T, Status> returned by ILanguageService, IDictionaryItemService, and IWebhookService, so a failed create/update (e.g. an ISO code rejected by Umbraco's IsoCodeValidator) was silently dropped while the import still reported success. Now throws when the attempt fails, so the failure surfaces in the import results and log instead of vanishing. Fixes #1038 Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent b2ed399 commit d5b2ce7

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

uSync.Core/Serialization/Serializers/DictionaryItemSerializer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,18 @@ private async Task<int> GetLevelAsync(IDictionaryItem item, int level = 0)
228228
}
229229

230230
public override async Task SaveItemAsync(IDictionaryItem item)
231-
=> _ = item.HasIdentity
231+
{
232+
var attempt = item.HasIdentity
232233
? await _dictionaryItemService.UpdateAsync(item, Constants.Security.SuperUserKey)
233234
: await _dictionaryItemService.CreateAsync(item, Constants.Security.SuperUserKey);
234235

236+
if (attempt.Success is false)
237+
{
238+
throw new InvalidOperationException(
239+
$"Could not save dictionary item {item.ItemKey}: {attempt.Status}");
240+
}
241+
}
242+
235243
public override Task DeleteItemAsync(IDictionaryItem item)
236244
=> _dictionaryItemService.DeleteAsync(item.Key, Constants.Security.SuperUserKey);
237245

uSync.Core/Serialization/Serializers/LanguageSerializer.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,18 @@ public override bool IsValid(XElement node)
152152
=> Task.FromResult(default(ILanguage));
153153

154154
public override async Task SaveItemAsync(ILanguage item)
155-
=> _ = item.HasIdentity
155+
{
156+
var attempt = item.HasIdentity
156157
? await _languageService.UpdateAsync(item, Constants.Security.SuperUserKey)
157158
: await _languageService.CreateAsync(item, Constants.Security.SuperUserKey);
158159

160+
if (attempt.Success is false)
161+
{
162+
throw new InvalidOperationException(
163+
$"Could not save language {item.IsoCode}: {attempt.Status}");
164+
}
165+
}
166+
159167
public override Task DeleteItemAsync(ILanguage item)
160168
=> _languageService.DeleteAsync(item.IsoCode, Constants.Security.SuperUserKey);
161169

uSync.Core/Serialization/Serializers/WebhookSerializer.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ public override string ItemAlias(IWebhook item)
5050
/// <inheritdoc/>
5151
///
5252
public override async Task SaveItemAsync(IWebhook item)
53-
=> _ = item.HasIdentity ? await _webhookService.UpdateAsync(item) : await _webhookService.CreateAsync(item);
53+
{
54+
var attempt = item.HasIdentity
55+
? await _webhookService.UpdateAsync(item)
56+
: await _webhookService.CreateAsync(item);
57+
58+
if (attempt.Success is false)
59+
{
60+
throw new InvalidOperationException(
61+
$"Could not save webhook {item.Key}: {attempt.Status}");
62+
}
63+
}
5464

5565
/// <inheritdoc/>
5666
protected override async Task<SyncAttempt<IWebhook>> DeserializeCoreAsync(XElement node, SyncSerializerOptions options)

0 commit comments

Comments
 (0)