Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[Android] Invalid user-agent for telemetry events (for some app names) #4354

Closed
erikandre opened this issue Mar 16, 2016 · 6 comments
Closed
Assignees
Labels
Android Mapbox Maps SDK for Android telemetry Integration with Mapbox Telemetry libraries

Comments

@erikandre
Copy link

If the app name contains characters that are not allowed in an HTTP header this will cause an exception in MapboxEventManager when dispatching the events.

As the user agent below indicates I'm using the 4.0.0 SNAPSHOT build (the one from March 15th I believe)

Doesn't crash the app, so not terribly critical (for me).


E/MapboxEventManager: FlushTheEventsTask borked: java.lang.IllegalArgumentException: Unexpected char 0xe4 at 11 in User-Agent value: Sveriges Fjäll/1.0/1 MapboxEventsAndroid/4.0.0-SNAPSHOT  
W/System.err: java.lang.IllegalArgumentException: Unexpected char 0xe4 at 11 in User-Agent value: Sveriges Fjäll/1.0/1 MapboxEventsAndroid/4.0.0-SNAPSHOT                                     
W/System.err:     at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:283)                                                                                                              
W/System.err:     at okhttp3.Headers$Builder.set(Headers.java:263)                                                                                                                            
W/System.err:     at okhttp3.Request$Builder.header(Request.java:165)                                                                                                                         
W/System.err:     at com.mapbox.mapboxsdk.telemetry.MapboxEventManager$FlushTheEventsTask.doInBackground(MapboxEventManager.java:622)                                                         
W/System.err:     at com.mapbox.mapboxsdk.telemetry.MapboxEventManager$FlushTheEventsTask.doInBackground(MapboxEventManager.java:516)                                                         
W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:292)                                                                                                                          
W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)                                                                                                                 
W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)                                                                                                            
W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)                                                                                          
W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)                                                                                          
W/System.err:     at java.lang.Thread.run(Thread.java:818)    
@tobrun
Copy link
Member

tobrun commented Mar 16, 2016

Thank you for reaching out but we ticketed this already in #4328. Closing.

@tobrun tobrun closed this as completed Mar 16, 2016
@erikandre
Copy link
Author

@tobrun Thanks! Just to be sure, in the linked ticket the events are successfully sent (I assume so based on the reference to staging) although the user agent string is a bit odd. In this case it fails to encode on the client.

@tobrun
Copy link
Member

tobrun commented Mar 21, 2016

Apologies, I was a bit too fast assuming it was related. This is indeed another problem.
After looking into this it appears that we are not able to encode ä. After checking the okhttp repo,
I have found this issue square/okhttp#891 (comment).
Since we are dynamically generating the user agent, we should sanitise the input.

cc @bleege

@tobrun tobrun reopened this Mar 21, 2016
@bleege bleege added Android Mapbox Maps SDK for Android refactor labels Mar 21, 2016
@bleege bleege added telemetry Integration with Mapbox Telemetry libraries and removed refactor labels Apr 4, 2016
@bleege bleege added this to the android-v4.1.0 milestone Apr 4, 2016
@bleege bleege self-assigned this Apr 4, 2016
@bleege
Copy link
Contributor

bleege commented Apr 4, 2016

I was able to solve this by reusing OkHttp's internal Util.toHumanReadableAscii() method to ensure that it's all Ascii all the time. Tested it out in the MapboxEventsManager and the newly created HttpTransportTest class using Swedish UA given above. Everything is 👌 .

@erikandre
Copy link
Author

Grëät! Thånk yöū @bleege :)

@bleege
Copy link
Contributor

bleege commented Apr 5, 2016

LOL!

Hopefully someday OkHttp will support Unicode so that we don't have to strip out the diacritics.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android telemetry Integration with Mapbox Telemetry libraries
Projects
None yet
Development

No branches or pull requests

3 participants