nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: firebase/firebase-admin-java
Pull request #109 (2017-12-07 21:40:31)

Renamed method as per the proposed API
go/firebase-admin-custom-claims


Patch:
diff --git a/src/main/java/com/google/firebase/auth/FirebaseAuth.java b/src/main/java/com/google/firebase/auth/FirebaseAuth.java
index 02ea5ad..dedb034 100644
--- a/src/main/java/com/google/firebase/auth/FirebaseAuth.java
+++ b/src/main/java/com/google/firebase/auth/FirebaseAuth.java
@@ -486,7 +486,7 @@ public class FirebaseAuth {
    * @throws IllegalArgumentException If the user ID string is null or empty, or the claims
    *     payload is invalid or too large.
    */
-  public ApiFuture<Void> setCustomClaimsAsync(String uid, Map<String, Object> claims) {
+  public ApiFuture<Void> setCustomUserClaimsAsync(String uid, Map<String, Object> claims) {
     return new TaskToApiFuture<>(setCustomClaims(uid, claims));
   }
 


Test patch:
diff --git a/src/test/java/com/google/firebase/auth/FirebaseAuthIT.java b/src/test/java/com/google/firebase/auth/FirebaseAuthIT.java
index d1433dc..9833ffc 100644
--- a/src/test/java/com/google/firebase/auth/FirebaseAuthIT.java
+++ b/src/test/java/com/google/firebase/auth/FirebaseAuthIT.java
@@ -322,7 +322,7 @@ public class FirebaseAuthIT {
 
       Map<String, Object> expected = ImmutableMap.<String, Object>of(
           "admin", true, "package", "gold");
-      auth.setCustomClaimsAsync(uid, expected).get();
+      auth.setCustomUserClaimsAsync(uid, expected).get();
 
       // Should have 2 claims
       UserRecord updatedUser = auth.getUserAsync(uid).get();
@@ -341,7 +341,7 @@ public class FirebaseAuthIT {
       }
 
       // Should be able to remove custom claims
-      auth.setCustomClaimsAsync(uid, null).get();
+      auth.setCustomUserClaimsAsync(uid, null).get();
       updatedUser = auth.getUserAsync(uid).get();
       assertTrue(updatedUser.getCustomClaims().isEmpty());
     } finally {
Repository: firebase/firebase-admin-java
Pull request #216 (2018-11-15 17:45:40)

fix FcmErrorCode error type


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a26bb32..54c45f6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
 # Unreleased
 
--
+- [fixed] Fixing error handling in FCM. The SDK now checks the key
+  type.googleapis.com/google.firebase.fcm.v1.FcmError to set error code.
 
 # v6.5.0
 
diff --git a/src/main/java/com/google/firebase/messaging/FirebaseMessaging.java b/src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
index 7ba1edd..efdd39d 100644
--- a/src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
+++ b/src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
@@ -56,7 +56,7 @@ public class FirebaseMessaging {
 
   private static final String FCM_URL = "https://fcm.googleapis.com/v1/projects/%s/messages:send";
   private static final String FCM_ERROR_TYPE =
-      "type.googleapis.com/google.firebase.fcm.v1.FcmErrorCode";
+      "type.googleapis.com/google.firebase.fcm.v1.FcmError";
 
   private static final String INTERNAL_ERROR = "internal-error";
   private static final String UNKNOWN_ERROR = "unknown-error";


Test patch:
diff --git a/src/test/java/com/google/firebase/messaging/FirebaseMessagingTest.java b/src/test/java/com/google/firebase/messaging/FirebaseMessagingTest.java
index b269978..0b8ce1c 100644
--- a/src/test/java/com/google/firebase/messaging/FirebaseMessagingTest.java
+++ b/src/test/java/com/google/firebase/messaging/FirebaseMessagingTest.java
@@ -278,14 +278,14 @@ public class FirebaseMessagingTest {
   }
 
   @Test
-  public void testSendErrorWithFcmErrorCode() throws Exception {
+  public void testSendErrorWithFcmError() throws Exception {
     MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
     FirebaseMessaging messaging = initMessaging(response);
     for (int code : HTTP_ERRORS) {
       response.setStatusCode(code).setContent(
           "{\"error\": {\"status\": \"INVALID_ARGUMENT\", \"message\": \"test error\", "
               + "\"details\":[{\"@type\": \"type.googleapis.com/google.firebase.fcm"
-              + ".v1.FcmErrorCode\", \"errorCode\": \"UNREGISTERED\"}]}}");
+              + ".v1.FcmError\", \"errorCode\": \"UNREGISTERED\"}]}}");
       TestResponseInterceptor interceptor = new TestResponseInterceptor();
       messaging.setInterceptor(interceptor);
       try {
Repository: firebase/firebase-admin-java
Pull request #217 (2018-11-16 01:02:38)

Getting more detailed errors from FCM back-end service
Related to #214 

b/119428403 for more context


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 54c45f6..b08e7c2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,7 +1,10 @@
 # Unreleased
 
 - [fixed] Fixing error handling in FCM. The SDK now checks the key
-  type.googleapis.com/google.firebase.fcm.v1.FcmError to set error code.
+  `type.googleapis.com/google.firebase.fcm.v1.FcmError` to set error
+  code.
+- [fixed] FCM errors sent by the back-end now include more details
+  that are helpful when debugging problems.
 
 # v6.5.0
 
diff --git a/src/main/java/com/google/firebase/messaging/FirebaseMessaging.java b/src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
index efdd39d..34ed364 100644
--- a/src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
+++ b/src/main/java/com/google/firebase/messaging/FirebaseMessaging.java
@@ -249,6 +249,7 @@ public class FirebaseMessaging {
         try {
           HttpRequest request = requestFactory.buildPostRequest(
               new GenericUrl(url), new JsonHttpContent(jsonFactory, payload.build()));
+          request.getHeaders().set("X-GOOG-API-FORMAT-VERSION", "2");
           request.setParser(new JsonObjectParser(jsonFactory));
           request.setResponseInterceptor(interceptor);
           response = request.execute();


Test patch:
diff --git a/src/test/java/com/google/firebase/messaging/FirebaseMessagingTest.java b/src/test/java/com/google/firebase/messaging/FirebaseMessagingTest.java
index 0b8ce1c..4b51513 100644
--- a/src/test/java/com/google/firebase/messaging/FirebaseMessagingTest.java
+++ b/src/test/java/com/google/firebase/messaging/FirebaseMessagingTest.java
@@ -512,6 +512,7 @@ public class FirebaseMessagingTest {
     assertEquals("POST", request.getRequestMethod());
     assertEquals(TEST_FCM_URL, request.getUrl().toString());
     assertEquals("Bearer test-token", request.getHeaders().getAuthorization());
+    assertEquals("2", request.getHeaders().get("X-GOOG-API-FORMAT-VERSION"));
     return request;
   }
Repository: firebase/firebase-admin-java
Pull request #251 (2019-02-19 22:01:11)

Revert "Fix for the uploadAccountResponse for correct error message/reason"
Reverts firebase/firebase-admin-java#244

Fix has been made in backend server and pushed to production.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5e92219..7763b85 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,6 @@
 
 - [changed] Removed org.json dependency and replaced with com.google.code.gson.
 - [changed] Upgraded Mockito dependency, and fixed the build on Java 11.
-- [fixed] UploadAccountResponse now has the correct error message/reason.
 
 # v6.7.0
 
diff --git a/src/main/java/com/google/firebase/auth/internal/UploadAccountResponse.java b/src/main/java/com/google/firebase/auth/internal/UploadAccountResponse.java
index 544617c..abf2853 100644
--- a/src/main/java/com/google/firebase/auth/internal/UploadAccountResponse.java
+++ b/src/main/java/com/google/firebase/auth/internal/UploadAccountResponse.java
@@ -35,7 +35,7 @@ public class UploadAccountResponse {
     @Key("index")
     private int index;
 
-    @Key("errorMessage")
+    @Key("message")
     private String message;
 
     public int getIndex() {


Test patch:
diff --git a/src/test/resources/importUsersError.json b/src/test/resources/importUsersError.json
index 6cffde2..9233f8a 100644
--- a/src/test/resources/importUsersError.json
+++ b/src/test/resources/importUsersError.json
@@ -1,6 +1,6 @@
 {
   "error": [
-    {"index": 0, "errorMessage": "Some error occurred in user1"},
-    {"index": 2, "errorMessage": "Another error occurred in user3"}
+    {"index": 0, "message": "Some error occurred in user1"},
+    {"index": 2, "message": "Another error occurred in user3"}
   ]
 }
Repository: firebase/firebase-admin-java
Pull request #333 (2019-12-09 22:34:47)

fix(fcm): Correctly handling FCM THIRD_PARTY_AUTH_ERROR error code
RELEASE NOTE: SDK now correctly handles the `THIRD_PARTY_AUTH_ERROR` error code returned by the backend service when sending notifications to iOS and web targets.


Patch:
diff --git a/src/main/java/com/google/firebase/messaging/FirebaseMessagingClientImpl.java b/src/main/java/com/google/firebase/messaging/FirebaseMessagingClientImpl.java
index 92dfd0c..c2659a2 100644
--- a/src/main/java/com/google/firebase/messaging/FirebaseMessagingClientImpl.java
+++ b/src/main/java/com/google/firebase/messaging/FirebaseMessagingClientImpl.java
@@ -67,14 +67,15 @@ final class FirebaseMessagingClientImpl implements FirebaseMessagingClient {
           .put("NOT_FOUND", "registration-token-not-registered")
           .put("PERMISSION_DENIED", "mismatched-credential")
           .put("RESOURCE_EXHAUSTED", "message-rate-exceeded")
-          .put("UNAUTHENTICATED", "invalid-apns-credentials")
+          .put("UNAUTHENTICATED", "third-party-auth-error")
 
           // FCM v1 new error codes
-          .put("APNS_AUTH_ERROR", "invalid-apns-credentials")
+          .put("APNS_AUTH_ERROR", "third-party-auth-error")
           .put("INTERNAL", FirebaseMessaging.INTERNAL_ERROR)
           .put("INVALID_ARGUMENT", "invalid-argument")
           .put("QUOTA_EXCEEDED", "message-rate-exceeded")
           .put("SENDER_ID_MISMATCH", "mismatched-credential")
+          .put("THIRD_PARTY_AUTH_ERROR", "third-party-auth-error")
           .put("UNAVAILABLE", "server-unavailable")
           .put("UNREGISTERED", "registration-token-not-registered")
           .build();


Test patch:
diff --git a/src/test/java/com/google/firebase/messaging/FirebaseMessagingClientImplTest.java b/src/test/java/com/google/firebase/messaging/FirebaseMessagingClientImplTest.java
index ae1136b..0b84e00 100644
--- a/src/test/java/com/google/firebase/messaging/FirebaseMessagingClientImplTest.java
+++ b/src/test/java/com/google/firebase/messaging/FirebaseMessagingClientImplTest.java
@@ -249,6 +249,24 @@ public class FirebaseMessagingClientImplTest {
     }
   }
 
+  @Test
+  public void testSendErrorWithThirdPartyError() {
+    for (int code : HTTP_ERRORS) {
+      response.setStatusCode(code).setContent(
+          "{\"error\": {\"status\": \"INVALID_ARGUMENT\", \"message\": \"test error\", "
+              + "\"details\":[{\"@type\": \"type.googleapis.com/google.firebase.fcm"
+              + ".v1.FcmError\", \"errorCode\": \"THIRD_PARTY_AUTH_ERROR\"}]}}");
+
+      try {
+        client.send(EMPTY_MESSAGE, DRY_RUN_DISABLED);
+        fail("No error thrown for HTTP error");
+      } catch (FirebaseMessagingException error) {
+        checkExceptionFromHttpResponse(error, "third-party-auth-error");
+      }
+      checkRequestHeader(interceptor.getLastRequest());
+    }
+  }
+
   @Test
   public void testSendAll() throws Exception {
     final TestResponseInterceptor interceptor = new TestResponseInterceptor();
Repository: firebase/firebase-admin-java
Pull request #339 (2019-12-19 17:04:06)

 Update project.json to include the .NET SDK.
The .NET SDK was missing from project.json, so this change simply adds it.


Patch:
diff --git a/.opensource/project.json b/.opensource/project.json
index 74e68f0..56484ef 100644
--- a/.opensource/project.json
+++ b/.opensource/project.json
@@ -7,6 +7,7 @@
     "content": "README.md",
     "pages": [],
     "related": [
+        "firebase/firebase-admin-dotnet",
         "firebase/firebase-admin-go",
         "firebase/firebase-admin-node",
         "firebase/firebase-admin-python"
diff --git a/src/main/java/com/google/firebase/messaging/AndroidNotification.java b/src/main/java/com/google/firebase/messaging/AndroidNotification.java
index 08a872c..05e6809 100644
--- a/src/main/java/com/google/firebase/messaging/AndroidNotification.java
+++ b/src/main/java/com/google/firebase/messaging/AndroidNotification.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
+import java.util.TimeZone;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -456,8 +457,9 @@ public class AndroidNotification {
      * @return This builder.
      */
     public Builder setEventTimeInMillis(long eventTimeInMillis) {
-      this.eventTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS'Z'")
-          .format(new Date(eventTimeInMillis));
+      SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS000000'Z'");
+      dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+      this.eventTime = dateFormat.format(new Date(eventTimeInMillis));
       return this;
     }
 


Test patch:
diff --git a/src/test/java/com/google/firebase/messaging/MessageTest.java b/src/test/java/com/google/firebase/messaging/MessageTest.java
index 5c8c3cb..778b4f1 100644
--- a/src/test/java/com/google/firebase/messaging/MessageTest.java
+++ b/src/test/java/com/google/firebase/messaging/MessageTest.java
@@ -859,15 +859,13 @@ public class MessageTest {
         .put("title", "title")
         .put("body", "body")
         .build();
-    String eventTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS'Z'", Locale.US)
-        .format(new Date(1546304523123L));
     Map<String, Object> androidConfig = ImmutableMap.<String, Object>builder()
         .put("notification", ImmutableMap.<String, Object>builder()
             .put("title", "android-title")
             .put("body", "android-body")
             .put("ticker", "ticker")
             .put("sticky", true)
-            .put("event_time", eventTime)
+            .put("event_time", "2019-01-01T01:02:03.123000000Z")
             .put("local_only", true)
             .put("notification_priority", "PRIORITY_HIGH")
             .put("vibrate_timings", ImmutableList.of("1s", "1.001000000s"))
Repository: firebase/firebase-admin-java
Pull request #576 (2021-06-28 15:56:01)

Drop 500 from the retryable errorcode list
[Google Cloud documentation](https://cloud.google.com/apis/design/errors#retrying_errors) has been updated to not consider 500 as a retryable error code. Update Admin SDK to align with that 

chong-shao: Thanks! 

Patch:
diff --git a/src/main/java/com/google/firebase/internal/ApiClientUtils.java b/src/main/java/com/google/firebase/internal/ApiClientUtils.java
index 723fc6d..e586bd1 100644
--- a/src/main/java/com/google/firebase/internal/ApiClientUtils.java
+++ b/src/main/java/com/google/firebase/internal/ApiClientUtils.java
@@ -34,7 +34,7 @@ public class ApiClientUtils {
 
   static final RetryConfig DEFAULT_RETRY_CONFIG = RetryConfig.builder()
       .setMaxRetries(4)
-      .setRetryStatusCodes(ImmutableList.of(500, 503))
+      .setRetryStatusCodes(ImmutableList.of(503))
       .setMaxIntervalMillis(60 * 1000)
       .build();
 


Test patch:
diff --git a/src/test/java/com/google/firebase/internal/ApiClientUtilsTest.java b/src/test/java/com/google/firebase/internal/ApiClientUtilsTest.java
index c19f5f5..f23c7a3 100644
--- a/src/test/java/com/google/firebase/internal/ApiClientUtilsTest.java
+++ b/src/test/java/com/google/firebase/internal/ApiClientUtilsTest.java
@@ -66,7 +66,7 @@ public class ApiClientUtilsTest {
     assertEquals(4, retryConfig.getMaxRetries());
     assertEquals(60 * 1000, retryConfig.getMaxIntervalMillis());
     assertFalse(retryConfig.isRetryOnIOExceptions());
-    assertEquals(retryConfig.getRetryStatusCodes(), ImmutableList.of(500, 503));
+    assertEquals(retryConfig.getRetryStatusCodes(), ImmutableList.of(503));
   }
 
   @Test
Repository: firebase/firebase-admin-java
Pull request #735 (2022-11-07 17:11:07)

Fix MultiDB Regression


Patch:
diff --git a/src/main/java/com/google/firebase/cloud/FirestoreClient.java b/src/main/java/com/google/firebase/cloud/FirestoreClient.java
index 1012017..e1672ec 100644
--- a/src/main/java/com/google/firebase/cloud/FirestoreClient.java
+++ b/src/main/java/com/google/firebase/cloud/FirestoreClient.java
@@ -79,7 +79,8 @@ public class FirestoreClient {
    */
   @NonNull
   public static Firestore getFirestore(FirebaseApp app) {
-    return getFirestore(app, ImplFirebaseTrampolines.getFirestoreOptions(app).getDatabaseId());
+    final FirestoreOptions firestoreOptions = ImplFirebaseTrampolines.getFirestoreOptions(app);
+    return getFirestore(app, firestoreOptions == null ? null : firestoreOptions.getDatabaseId());
   }
 
   /**


Test patch:
diff --git a/src/test/java/com/google/firebase/cloud/FirestoreClientTest.java b/src/test/java/com/google/firebase/cloud/FirestoreClientTest.java
index a5f617c..31ea336 100644
--- a/src/test/java/com/google/firebase/cloud/FirestoreClientTest.java
+++ b/src/test/java/com/google/firebase/cloud/FirestoreClientTest.java
@@ -79,6 +79,20 @@ public class FirestoreClientTest {
     assertNotSame(firestore1, firestore2);
   }
 
+  @Test
+  public void testAbsentFirestoreOptions() throws Exception {
+    String projectId = "test-proj";
+    FirebaseOptions options = FirebaseOptions.builder()
+        .setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream()))
+        .setProjectId(projectId)
+        .build();
+
+    FirebaseApp.initializeApp(options);
+    Firestore firestore = FirestoreClient.getFirestore();
+    assertEquals(projectId, firestore.getOptions().getProjectId());
+    assertEquals("(default)", firestore.getOptions().getDatabaseId());
+  }
+
   @Test
   public void testFirestoreOptions() throws IOException {
     final String databaseId = "databaseIdInTestFirestoreOptions";