Skip to content

Commit ecef4e2

Browse files
fixed error
1 parent df677c8 commit ecef4e2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

AcmeCaPlugin/Clients/DNS/CloudflareDnsProvider.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ public async Task<bool> DeleteRecordAsync(string recordName)
6767
var json = await recordsResp.Content.ReadAsStringAsync();
6868
var doc = JsonDocument.Parse(json);
6969

70-
var recordId = doc.RootElement.GetProperty("result").EnumerateArray()
71-
.FirstOrDefault().GetProperty("id").GetString();
70+
var resultArray = doc.RootElement.GetProperty("result");
71+
if (resultArray.GetArrayLength() == 0) return false;
72+
var recordId = resultArray[0].GetProperty("id").GetString();
7273

7374
if (recordId == null) return false;
7475

@@ -86,9 +87,9 @@ public async Task<bool> DeleteRecordAsync(string recordName)
8687

8788
var json = await response.Content.ReadAsStringAsync();
8889
var doc = JsonDocument.Parse(json);
89-
var results = doc.RootElement.GetProperty("result").EnumerateArray();
90-
if (!results.Any()) return null;
91-
return results.First().GetProperty("id").GetString();
90+
var resultArray = doc.RootElement.GetProperty("result");
91+
if (resultArray.GetArrayLength() == 0) return null;
92+
return resultArray[0].GetProperty("id").GetString();
9293
}
9394

9495
private async Task<(string? zoneName, string? zoneId)> FindZoneForRecordAsync(string recordName)

0 commit comments

Comments
 (0)