nilsbraden / ttrss-reader-fork

An Android-Client for the self-hosted Tiny Tiny RSS feedreader
https://www.nilsbraden.de/TTRSS-Reader/
149 stars 40 forks source link

Crash after TTRSS update past commit 2adf364c2c: Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 84 path $.content.config #451

Closed aruberutsu closed 3 years ago

aruberutsu commented 3 years ago

After upgrading TTRSS instance to commit 2adf364c2c or newer, TTRSS-Reader will crash on login with the following error:

2021-05-21 16:10:44.256 6613-6662/org.ttrssreader E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #3
    Process: org.ttrssreader, PID: 6613
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at org.ttrssreader.utils.AsyncTask$4.done(AsyncTask.java:218)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: java.lang.IllegalStateException: Expected a string but was BEGIN_OBJECT at line 1 column 84 path $.content.config
        at com.google.gson.stream.JsonReader.nextString(JsonReader.java:826)
        at org.ttrssreader.net.JSONConnector.readResult(JSONConnector.java:319)
        at org.ttrssreader.net.JSONConnector.internalLogin(JSONConnector.java:526)
        at org.ttrssreader.net.JSONConnector.sessionNotAlive(JSONConnector.java:451)
        at org.ttrssreader.net.JSONConnector.getHeadlines(JSONConnector.java:978)
        at org.ttrssreader.controllers.Data.cacheArticles(Data.java:168)
        at org.ttrssreader.gui.CategoryActivity$CategoryUpdater.doInBackground(CategoryActivity.java:254)
        at org.ttrssreader.gui.CategoryActivity$CategoryUpdater.doInBackground(CategoryActivity.java:227)
        at org.ttrssreader.utils.AsyncTask$3.call(AsyncTask.java:199)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923) 

Indeed, after applying this update, TTRSS returns a "config" object in the login message that TTRSS-Reader is not expecting:

# Version: 2adf364c2c
$ curl -X POST https://example.com/ttrss/api/index.php -H "Content-Type: text/json;charset=UTF-8" -d '{"op":"login","user":"debug","password":"mysecretpass"}'
{"seq":0,"status":0,"content":{"session_id":"n7k9z32g5us1980i2kms9284jm","config":{"icons_dir":"feed-icons","icons_url":"feed-icons","daemon_is_running":false,"custom_sort_types":[],"num_feeds":1},"api_level":16}}

# Version: 9f6237a1b8
$ curl -X POST https://example.com/ttrss/api/index.php -H "Content-Type: text/json;charset=UTF-8" -d '{"op":"login","user":"debug","password":"mysecretpass"}'
{"seq":0,"status":0,"content":{"session_id":"fpf54n7k9z38llpr5n5vg4ura3","api_level":16}}

As a workaround, one can keep the server (or go back if accidentaly updated with git checkout) at 9f6237a1b8.

TwizzyDizzy commented 3 years ago

Just wanted to report this. Can confirm anything above.

Cheers Thomas

nilsbraden commented 3 years ago

Thanks for reporting, wouldn't have noticed it otherwise since I hardly ever think about updating the server at the moment...

I fixed it by parsing the config if it is provided, values are stored in Controller and in case of feed-icons url it is used if it differs from the configured value in the user preferences. In that case the outdated value in the preferences is also updated to avoid trouble later on, I guess if the server provides a value we can savely accept it.

TwizzyDizzy commented 3 years ago

The fix has arrived in F-Droid. Installed it today, updated to HEAD of Tiny Tiny rss and... the app crashed.

That being said: deleting app cache and app data (and re-entering all credentials and stuff) the issue was gone and the app is fully functional again.

Cheers Thomas