Skip to content

Commit 72f3448

Browse files
committed
fix(remoteconfig): catch parsing runtime exceptions in fromJSON to stabilize headless pipelines
1 parent 330aa89 commit 72f3448

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/main/java/com/google/firebase/remoteconfig/ServerTemplateData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ static ServerTemplateData fromJSON(@NonNull String json)
9393
ServerTemplateResponse serverTemplateResponse =
9494
jsonFactory.createJsonParser(json).parseAndClose(ServerTemplateResponse.class);
9595
return new ServerTemplateData(serverTemplateResponse);
96-
} catch (IOException e) {
96+
} catch (Exception e) {
9797
throw new FirebaseRemoteConfigException(
98-
ErrorCode.INVALID_ARGUMENT, "Unable to parse JSON string.");
98+
ErrorCode.INVALID_ARGUMENT, "Unable to parse JSON string.", e);
9999
}
100100
}
101101

src/main/java/com/google/firebase/remoteconfig/Template.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ public static Template fromJSON(@NonNull String json) throws FirebaseRemoteConfi
106106
TemplateResponse templateResponse = jsonFactory.createJsonParser(json)
107107
.parseAndClose(TemplateResponse.class);
108108
return new Template(templateResponse);
109-
} catch (IOException e) {
110-
throw new FirebaseRemoteConfigException(ErrorCode.INVALID_ARGUMENT,
111-
"Unable to parse JSON string.");
109+
} catch (Exception e) {
110+
throw new FirebaseRemoteConfigException(
111+
ErrorCode.INVALID_ARGUMENT, "Unable to parse JSON string.", e);
112112
}
113113
}
114114

src/test/java/com/google/firebase/phonenumberverification/internal/FirebasePhoneNumberVerificationTokenVerifierTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,8 @@ public void testVerifyToken_EmptyProjectId() {
431431
+ " \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n"
432432
+ " \"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\n"
433433
+ " \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n"
434-
+ " \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/mock-project-id-none%40mock-project-id.iam.gserviceaccount.com\"\n"
434+
+ " \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/"
435+
+ "mock-project-id-none%40mock-project-id.iam.gserviceaccount.com\"\n"
435436
+ "}";
436437

437438
FirebaseOptions localFirebaseOptions = FirebaseOptions.builder()

0 commit comments

Comments
 (0)