Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote Config fetch fails below API 19 (Kitkat) #973

Closed
Protino opened this issue Nov 12, 2019 · 6 comments
Closed

Remote Config fetch fails below API 19 (Kitkat) #973

Protino opened this issue Nov 12, 2019 · 6 comments
Assignees
Labels
api: remoteconfig type: bug Something isn't working

Comments

@Protino
Copy link

Protino commented Nov 12, 2019

Describe your environment

  • Android Studio version: 3.5.1
  • Firebase Component: Remote Config (Database, Firestore, Storage, Functions, etc)
  • Component version: 19.0.3
  • Issue found on: API 17 (Below Kitkat)

Describe the problem

Firebase remote config fails to fetch config values on API level below 19. Exception thrown is FirebaseRemoteConfigServerException: Bad Request.

Steps to reproduce:

Run the official sample code - https://github.com/firebase/quickstart-android/tree/master/config on any API 17 emulator.
Click on 'Run the java version ...'

  • What happened
    Fetch fails and the exception thrown is com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException with message - Bad request.

Complete trace -

    com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException: Fetch failed: The server returned an unexpected error.
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.createExceptionWithGenericMessage(com.google.firebase:firebase-config@@19.0.3:351)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackend(com.google.firebase:firebase-config@@19.0.3:304)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackendAndCacheResponse(com.google.firebase:firebase-config@@19.0.3:251)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchIfCacheExpiredAndNotThrottled(com.google.firebase:firebase-config@@19.0.3:191)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.lambda$fetch$0(com.google.firebase:firebase-config@@19.0.3:160)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$Lambda$1.then(com.google.firebase:firebase-config@@19.0.3)
        at com.google.android.gms.tasks.zzf.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
        at java.lang.Thread.run(Thread.java:841)
     Caused by: com.google.firebase.remoteconfig.FirebaseRemoteConfigServerException: Bad Request
        at com.google.firebase.remoteconfig.internal.ConfigFetchHttpClient.fetch(com.google.firebase:firebase-config@@19.0.3:189)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackend(com.google.firebase:firebase-config@@19.0.3:278)
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchFromBackendAndCacheResponse(com.google.firebase:firebase-config@@19.0.3:251) 
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.fetchIfCacheExpiredAndNotThrottled(com.google.firebase:firebase-config@@19.0.3:191) 
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler.lambda$fetch$0(com.google.firebase:firebase-config@@19.0.3:160) 
        at com.google.firebase.remoteconfig.internal.ConfigFetchHandler$$Lambda$1.then(com.google.firebase:firebase-config@@19.0.3) 
        at com.google.android.gms.tasks.zzf.run(Unknown Source) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 

Upon further inspection, looks like the analyticsUserProperties user property is wrongly formatted in the request body.
on API 17 -

{
	"platformVersion": "17",
	"languageCode": "en_GB",
	"analyticsUserProperties": "{}",
	"appId": "[REDACTED]",
	"packageName": "com.google.firebase.quickstart.invites",
	"appVersion": "1.0",
	"appInstanceId": "REDACTED",
	"appInstanceIdToken": "REDACTED",
	"countryCode": "GB",
	"timeZone": "Asia\/Calcutta",
	"sdkVersion": "19.0.3"
}

Response -

{
	"error": {
		"code": 400,
		"message": "Invalid value at 'analytics_user_properties' (type.googleapis.com/google.firebase.remoteconfig.v1.FetchRemoteConfigRequest.AnalyticsUserPropertiesEntry), \"{}\"",
		"status": "INVALID_ARGUMENT",
		"details": [{
			"@type": "type.googleapis.com/google.rpc.BadRequest",
			"fieldViolations": [{
				"field": "analytics_user_properties",
				"description": "Invalid value at 'analytics_user_properties' (type.googleapis.com/google.firebase.remoteconfig.v1.FetchRemoteConfigRequest.AnalyticsUserPropertiesEntry), \"{}\""
			}]
		}]
	}
}

on API 21 -

{
	"platformVersion": "17",
	"languageCode": "en_GB",
	"analyticsUserProperties": {},
	"appId": "[REDACTED]",
	"packageName": "com.google.firebase.quickstart.invites",
	"appVersion": "1.0",
	"appInstanceId": "REDACTED",
	"appInstanceIdToken": "REDACTED",
	"countryCode": "GB",
	"timeZone": "Asia\/Calcutta",
	"sdkVersion": "19.0.3"
}

If JSONObject().toString() is done on a nested map objects it produces "{}" instead of just {}, on API(17). If someone could explain this that would be doubly helpful, thanks.

Between, on remote config version 18.0.0 it works fine.

@google-oss-bot
Copy link
Contributor

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@Protino
Copy link
Author

Protino commented Nov 18, 2019

Can someone please add needs-attention tag to this. This is happening live on the 19.x version and completely fails below Kitkat.

@Protino Protino closed this as completed Nov 18, 2019
@Protino Protino changed the title Remote Config fetch fails below API 19 Remote Config fetch fails below API 19 (Kitkat) Nov 18, 2019
@Protino Protino reopened this Nov 18, 2019
@clp93 clp93 self-assigned this Nov 19, 2019
@aguatno
Copy link

aguatno commented Nov 19, 2019

Internally tracked at b/144365875.

@aguatno aguatno added type: bug Something isn't working and removed needs-attention labels Nov 19, 2019
clp93 added a commit that referenced this issue Nov 20, 2019
* Explicitly create JSONObject from user properties map

* Run Bandwagoner Test App and tests on API level 16

* Fix with API 19 and below #973
@clp93
Copy link
Contributor

clp93 commented Nov 20, 2019

Hey @Protino, submitted a fix that should go out sometime soon. Please follow https://firebase.google.com/support/release-notes/android to find out when the fix is in production. In the meantime, you could build the SDK from master and include that in your app if a fix is required immediately.

@Protino
Copy link
Author

Protino commented Nov 21, 2019

@clp93 Thanks. Not immediately required as of now, will continue to use 18.0.0. Will close the issue once a fix is available in production.

thebrianchen pushed a commit that referenced this issue Dec 3, 2019
* Explicitly create JSONObject from user properties map

* Run Bandwagoner Test App and tests on API level 16

* Fix with API 19 and below #973
@clp93
Copy link
Contributor

clp93 commented Dec 10, 2019

Hey @Protino, RC SDK Version 19.0.4 should have the fix you're looking for.

We've verified that the regression was not observed on our test devices running API 18 with the new SDK, and as such, I'll mark the issue as closed.

Thanks for the report!

@clp93 clp93 closed this as completed Dec 10, 2019
@firebase firebase locked and limited conversation to collaborators Jan 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: remoteconfig type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants