maryvilledev / codesplainUI

Web app for breaking down and annotating Python 3 source code.
https://www.codesplain.io
GNU General Public License v3.0
2 stars 2 forks source link

Handle users with no index.json #411

Closed Hopding closed 7 years ago

Hopding commented 7 years ago

Expected Behavior

When a user logs in, and they do not have an index.json file in their S3 bucket (or they are new, and have no S3 bucket at all), the snippet list option in the app menu should not expand (or should be disabled).

Current Behavior

Currently, if a user logs in and they do not have an index.json file, the following XHR request is performed:

screen shot 2017-04-17 at 4 39 43 pm

And when they expand their "My Snippets" option, they get an infinitely long empty list:

screen shot 2017-04-17 at 4 43 50 pm

This is because the axios call that requests their index.json file does not actually fail, as one would expect: https://github.com/maryvilledev/codesplainUI/blob/master/src/actions/user.js#L48. Instead, it succeeds with a 200 status code, but the body of the response is:

<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>Hopding/index.json</Key><RequestId>D4B75D9E07E90D9B</RequestId><HostId>227x9z160TTI1aRFELNU115TsDji6/FLuYidrd5hsROou0eA4D3QJBz0BVvw6Ra0n9vgIg1x/NE=</HostId></Error>

This is not properly handled anywhere, and seems to be causing the infinite empty list.

Steps to Reproduce (for bugs)

  1. Remove your index.json file from the dev S3 bucket.
  2. Log out of Codesplain.
  3. Log in to Codesplain.
  4. Expand your "My Snippets" list.

Possible Solution

Perhaps search the response body for <Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message>, and throw an error if it exists in the body, thus jumping into the catch statement of the Promise chain.