{"action":"created","issue":{"url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/5011","repository_url":"https://api.github.com/repos/ankidroid/Anki-Android","labels_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/5011/labels{/name}","comments_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/5011/comments","events_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/5011/events","html_url":"https://github.com/ankidroid/Anki-Android/issues/5011","id":366607835,"node_id":"MDU6SXNzdWUzNjY2MDc4MzU=","number":5011,"title":"State handling crash between card browser / note editor / template editor","user":{"login":"mikehardy","id":782704,"node_id":"MDQ6VXNlcjc4MjcwNA==","avatar_url":"https://avatars1.githubusercontent.com/u/782704?v=4","gravatar_id":"","url":"https://api.github.com/users/mikehardy","html_url":"https://github.com/mikehardy","followers_url":"https://api.github.com/users/mikehardy/followers","following_url":"https://api.github.com/users/mikehardy/following{/other_user}","gists_url":"https://api.github.com/users/mikehardy/gists{/gist_id}","starred_url":"https://api.github.com/users/mikehardy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikehardy/subscriptions","organizations_url":"https://api.github.com/users/mikehardy/orgs","repos_url":"https://api.github.com/users/mikehardy/repos","events_url":"https://api.github.com/users/mikehardy/events{/privacy}","received_events_url":"https://api.github.com/users/mikehardy/received_events","type":"User","site_admin":false},"labels":[{"id":1062808653,"node_id":"MDU6TGFiZWwxMDYyODA4NjUz","url":"https://api.github.com/repos/ankidroid/Anki-Android/labels/2.8.x","name":"2.8.x","color":"1d76db","default":false},{"id":241429239,"node_id":"MDU6TGFiZWwyNDE0MjkyMzk=","url":"https://api.github.com/repos/ankidroid/Anki-Android/labels/accepted","name":"accepted","color":"bfe5bf","default":false},{"id":241409190,"node_id":"MDU6TGFiZWwyNDE0MDkxOTA=","url":"https://api.github.com/repos/ankidroid/Anki-Android/labels/bug","name":"bug","color":"fc2929","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-10-04T03:24:39Z","updated_at":"2018-10-11T15:50:37Z","closed_at":null,"author_association":"MEMBER","body":"\r\nI've seen this show up via ACRA, and the google play console release robot army caught it with video this time so I could figure it out.\r\n\r\n###### Reproduction Steps\r\n\r\n1. Open the card browser (it's empty in their tests, and they play with searches sometimes but the search was cleared)\r\n2. Click + to add a card, enter text in front and back, template should be Basic\r\n3. click the button bar that says \"Card 1\" to open the template editor\r\n4. Click the options menu and select add to add a Card to the template, and you can mess with the template or not, but don't save - preview or not but don't save - then click the back button and agree it's okay to lose your progress\r\n5. The Card button bar should say \"Cards: Card 1 Card 2\" now, but you never saved the second template\r\n6. Click save to add the card, then click back to go back to the browser and it should crash with a JSONException string out of bounds\r\n\r\n\r\n###### Expected Result\r\n\r\nIf you don't save the template the unsaved work should go away, you should have only Card 1 and the browser should work fine\r\n\r\n\r\n###### Actual Result\r\n\r\nCrash. I can reproduce this locally.\r\n\r\nhttps://play.google.com/apps/publish/?account=5338425030304417978#PreLaunchReportPlace:p=com.ichi2.anki&appid=4973711737547064258&plrtab=CRASH&plrvc=20900140\r\n\r\nFATAL EXCEPTION: AsyncTask #4\r\nProcess: com.ichi2.anki, PID: 12740\r\njava.lang.RuntimeException: An error occurred while executing doInBackground()\r\n\tat android.os.AsyncTask$3.done(AsyncTask.java:353)\r\n\tat java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)\r\n\tat java.util.concurrent.FutureTask.setException(FutureTask.java:252)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:271)\r\n\tat android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)\r\n\tat java.lang.Thread.run(Thread.java:764)\r\nCaused by: java.lang.RuntimeException: org.json.JSONException: Index 1 out of range [0..1)\r\n\tat com.ichi2.libanki.Card.template(Card.java:342)\r\n\tat com.ichi2.libanki.Card._getQA(Card.java:290)\r\n\tat com.ichi2.anki.CardBrowser.updateSearchItemQA(CardBrowser.java:1164)\r\n\tat com.ichi2.async.DeckTask.doInBackgroundSearchCards(DeckTask.java:818)\r\n\tat com.ichi2.async.DeckTask.doInBackground(DeckTask.java:262)\r\n\tat com.ichi2.async.DeckTask.doInBackground(DeckTask.java:69)\r\n\tat android.os.AsyncTask$2.call(AsyncTask.java:333)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\r\n\t... 4 more\r\nCaused by: org.json.JSONException: Index 1 out of range [0..1)\r\n\tat org.json.JSONArray.get(JSONArray.java:293)\r\n\tat org.json.JSONArray.getJSONObject(JSONArray.java:521)\r\n\tat com.ichi2.libanki.Card.template(Card.java:337)\r\n\t... 11 more\r\nCaused by: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1\r\n\tat java.util.ArrayList.get(ArrayList.java:437)\r\n\tat org.json.JSONArray.get(JSONArray.java:287)\r\n\t... 13 more\r\n\r\n\r\n###### Debug info\r\nRefer to the [support page](https://ankidroid.org/docs/help.html) if you are unsure where to get the \"debug info\".\r\n\r\n###### Research\r\n*Enter an [ x ] character to confirm the points below:*\r\n\r\n[  ] I have read the [support page](https://ankidroid.org/docs/help.html) and am reporting a bug or enhancement request specific to AnkiDroid\r\n\r\n[  ] I have checked the [manual](https://ankidroid.org/docs/manual.html) and the [FAQ](https://github.com/ankidroid/Anki-Android/wiki/FAQ) and could not find a solution to my issue\r\n\r\n[  ] I have searched for similar existing issues here and on the user forum\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/comments/429008821","html_url":"https://github.com/ankidroid/Anki-Android/issues/5011#issuecomment-429008821","issue_url":"https://api.github.com/repos/ankidroid/Anki-Android/issues/5011","id":429008821,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTAwODgyMQ==","user":{"login":"mikehardy","id":782704,"node_id":"MDQ6VXNlcjc4MjcwNA==","avatar_url":"https://avatars1.githubusercontent.com/u/782704?v=4","gravatar_id":"","url":"https://api.github.com/users/mikehardy","html_url":"https://github.com/mikehardy","followers_url":"https://api.github.com/users/mikehardy/followers","following_url":"https://api.github.com/users/mikehardy/following{/other_user}","gists_url":"https://api.github.com/users/mikehardy/gists{/gist_id}","starred_url":"https://api.github.com/users/mikehardy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikehardy/subscriptions","organizations_url":"https://api.github.com/users/mikehardy/orgs","repos_url":"https://api.github.com/users/mikehardy/repos","events_url":"https://api.github.com/users/mikehardy/events{/privacy}","received_events_url":"https://api.github.com/users/mikehardy/received_events","type":"User","site_admin":false},"created_at":"2018-10-11T15:50:37Z","updated_at":"2018-10-11T15:50:37Z","author_association":"MEMBER","body":"Yeah - that's the last bit I'm working on now - pretty messy. I'm patching it up this style (which I will call \"template editor persists speculative edits\") but what a mess! At some point this thing needs to change to \"persists when save is tapped\"..."}}
{"actor":{"display_login":"mikehardy"}}