Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to handle errors on startup properly #11

Open
qdonnellan opened this issue Oct 28, 2016 · 2 comments
Open

Need to handle errors on startup properly #11

qdonnellan opened this issue Oct 28, 2016 · 2 comments

Comments

@qdonnellan
Copy link
Contributor

If a bot is initiated with improper credentials (e.g. a bad username, mistmatched user/pass credentials) we need actually catch that error and report it back to the user with a meaningful traceback; currently the user gets this unhelpful response:

flow.flow.FlowError: runtime error: invalid memory address or nil pointer dereference

What's happening is here: https://github.com/SpiderOak/flowbot/blob/master/src/server.py#L27

We have a series of try ... except... blocks that mask any useful Exceptions. If at the end of those blocks the server connection isn't established, any further interaction with the server will fail with the pointer error above, because the connection doesn't exist.

@jeancochrane
Copy link

I keep getting tripped up on this error message while trying to build a bot. What constitutes improper credentials? Do you have to register the bot's credentials before running it? My impression from the docs was that I could assign it a username and password in settings.json, and then if the bot didn't already exist it would create the account and ask to join the team. Instead, it gets caught in account authentication errors.

I'm building a modified version of the Twitter bot (although when I cloned the respondbot and used the same credentials I got an identical log). I'm using the username TwitterBot, a randomly-generated password of three words separated by hyphens, and our 52-digit org ID (copied to the clipboard from the Semaphor app).

Here's my error log (minus passwords, tokens, device names, and our team ID):

DEBUG:flow:request: id=Q7R47HYLZS, {'method': 'Config', 'params': [{'FlowLocalDatabaseDir': '/Users/jeancochrane/Library/Application Support/flow-python', 'FlowLocalAttachmentDir': '/Users/jeancochrane/Library/Application Support/flow-python/downloads', 'FlowServPort': '443', 'FlowServHost': 'flow.spideroak.com', 'FlowLocalSchemaDir': '/Applications/Semaphor.app/Contents/Resources/app/schema', 'FlowUseTLS': 'true'}], 'token': '<token>'}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:64148 "POST /rpc HTTP/1.1" 200 35
DEBUG:flow:response: id=Q7R47HYLZS, Config, HTTP=200, lat=0.02s, {'error': '', 'result': None}
DEBUG:flow:request: id=V3QPQHS52T, {'method': 'NewSession', 'params': [{}], 'token': '<token>'}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:64148 "POST /rpc HTTP/1.1" 200 55
DEBUG:flow:response: id=V3QPQHS52T, NewSession, HTTP=200, lat=0.01s, {'error': '', 'result': {'SessionID': 1}}
DEBUG:flow:request: id=LW9NTY4CRH, {'method': 'StartUp', 'params': [{'SessionID': 1, 'ServerURI': 'flow.spideroak.com', 'Username': 'TwitterBot'}], 'token': '<token>'}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:64148 "POST /rpc HTTP/1.1" 200 48
DEBUG:flow:response: id=LW9NTY4CRH, StartUp, HTTP=200, lat=0.02s, {'error': 'Unknown account', 'result': ''}
DEBUG:flowbot.server:start_up failed: 'Unknown account'
DEBUG:flow:request: id=12THMJXXAG, {'method': 'CreateDevice', 'params': [{'SessionID': 1, 'ServerURI': 'flow.spideroak.com', 'Username': 'TwitterBot', 'Platform': 'darwin', 'OSRelease': '15.6.0', 'Password': '<password>', 'DeviceName': '<device-name>'}], 'token': '<token>'}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:64148 "POST /rpc HTTP/1.1" 200 74
DEBUG:flow:response: id=12THMJXXAG, CreateDevice, HTTP=200, lat=0.81s, {'error': 'Account Not Found Or Authentication Error', 'result': ''}
DEBUG:flowbot.server:Create device failed: 'Account Not Found Or Authentication Error'
DEBUG:flow:request: id=RYH9HV6T3Z, {'method': 'CreateAccount', 'params': [{'NotifyToken': '', 'SessionID': 1, 'ServerURI': 'flow.spideroak.com', 'DeviceName': '<device-name>', 'EmailConfirmCode': None, 'PhoneNumber': '599506850120440', 'TotpVerifier': '566950091364128', 'OSRelease': '15.6.0', 'Platform': 'darwin', 'Username': 'TwitterBot', 'Password': '<password>'}], 'token': '<token>'}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:64148 "POST /rpc HTTP/1.1" 200 48
DEBUG:flow:response: id=RYH9HV6T3Z, CreateAccount, HTTP=200, lat=0.41s, {'error': 'Duplicate entry', 'result': ''}
DEBUG:flowbot.server:Create account failed: 'Duplicate entry'
DEBUG:flow:request: id=JKBQB21BPY, {'method': 'NewOrgJoinRequest', 'params': [{'SessionID': 1, 'OrgID': '<org_id>'}], 'token': '<token>'}
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:64148 "POST /rpc HTTP/1.1" 500 None
DEBUG:flow:response: id=JKBQB21BPY, NewOrgJoinRequest, HTTP=500, lat=0.00s, {'Error': 'runtime error: invalid memory address or nil pointer dereference\ngoroutine 113 [running]:

From there it spits out the error message to print.

Let me know if you need any more information. Excited to get this working!

@qdonnellan
Copy link
Contributor Author

@jeancochrane thanks for the note! You are correct in assuming that you can simply create a new username/password for the bot (it does not need to be created in-app; and actually it shouldn't be.) I believe that this error:

runtime error: invalid memory address or nil pointer dereference\ngoroutine

... is raised when the flow (Semaphor) service is not currently running, which is typically a result of an invalid username/password, or using an illegal username. Illegal usernames are are ones that are either already taken or that have an invalid character (like spaces).

My best advice at this point is to try with a different user/pass using only alphanumerics for the username.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants