Skip to content

Commit 835e0c5

Browse files
authored
fix: classify microsoft quotaLimitReached code as dest. full (#1447)
unfortunately this isn't perfectly correct; `quotaLimitReached` can mean storage quota but _appears_ it also can be used to mean rate-limiting. Unclear, for now.
1 parent fa5d7b1 commit 835e0c5

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

extensions/data-transfer/portability-data-transfer-microsoft/src/main/java/org/datatransferproject/transfer/microsoft/MicrosoftApiResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private FatalState toFatalState() {
223223
}
224224
// Nit: we _could_ just parse the body into json properly and make sure the JSON body "message"
225225
// field has this string. This seems fine for now.
226-
if (httpStatus() == 507 && bodyContains("Insufficient Space Available")) {
226+
if (httpStatus() == 507 && (bodyContains("Insufficient Space Available") || bodyContains("quotaLimitReached"))) {
227227
return FatalState.FATAL_STATE_FATAL_DESTINATION_FULL;
228228
}
229229
return FatalState.FATAL_STATE_FATAL_UNSPECIFIED;

extensions/data-transfer/portability-data-transfer-microsoft/src/test/java/org/datatransferproject/transfer/microsoft/MicrosoftApiResponseTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,29 @@ public void testDestinationFull() throws IOException {
9595
});
9696
}
9797

98+
// Alternative way Microsoft APIs respond with destination-full errors.
99+
@Test
100+
public void testDestinationFull_quotaLimitReached() throws IOException {
101+
Response networkResponse = fakeResponse(507, "",
102+
"{" +
103+
"\"error\": {" +
104+
"\"code\":\"quotaLimitReached\"," +
105+
"\"message\":\"Quota limit reached\"," +
106+
"\"innerError\": {\"date\":\"2024-12-12T13:30:20\",\"request-id\":\"fake-request-id\",\"client-request-id\":\"fake-client-request-id\"}" +
107+
"}" +
108+
"}"
109+
).build();
110+
111+
MicrosoftApiResponse response = MicrosoftApiResponse.ofResponse(networkResponse);
112+
113+
assertThat(response.isOkay()).isFalse();
114+
assertThrows(
115+
DestinationMemoryFullException.class,
116+
() -> {
117+
response.throwDtpException("unit testing");
118+
});
119+
}
120+
98121
@Test
99122
public void testErrorUnknown() throws IOException {
100123
Response networkResponse =

0 commit comments

Comments
 (0)