JakeWharton / JakeWharton/u2020
Setting invalid custom endpoint breaks the app
- Dominant language
- Java
- Stars
- 5.6k
- Forks
- 907
- PR merge metrics
- No merged PRs in 30d
Description
Setting endpoint to custom with value that is not parseable (e.g "saffga") will make the app crash. It will crash on every consequent startup until the app data is cleared.
The reason is that the user inputed string is saved to `@ApiEndpoint` String preference, which is later read by `provideHttpUrl` method in `DebugApiModule`. The method tries to parse the String into `HttpUrl` but invalid Strings are parsed to `null` value. When `null` `HttpUrl` is provided as a base url when building retrofit instance, the app will crash.
Fix: Make sure user provided custom URL is parseable. Additional validation is required when custom endpoint is set by the user(within `DebugView`, check if it is parseable by `HttpUrl.parse()` method). I've made pull request for this but I guess I'm not allowed to push anything to this repo.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in DebugView, where the custom endpoint is set, and inspect DebugApiModule's provideHttpUrl method to follow how the saved @ApiEndpoint value is parsed. Verify that an invalid custom URL is rejected before it is saved, and confirm that restarting the app no longer crashes with an invalid input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100