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

Spond.get_event() and Spond.get_group() fail with unexpected TypeError if no events/groups are available #136

Open
elliot-100 opened this issue Jun 25, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@elliot-100
Copy link
Collaborator

elliot-100 commented Jun 25, 2024

get_event() and get_group() call get_events() and get_groups(), which return None if no events/groups are available.

(Until I looked at it properly, I thought they returned empty lists.)

This appears to cause problems:

>       await s.get_event("ID1")

...
        if not self.events:
            await self.get_events()
        for event in self.events:
>           if event["id"] == uid:
E           TypeError: string indices must be integers

..\spond\spond.py:312: TypeError

I'm looking into this.

@elliot-100 elliot-100 added the bug Something isn't working label Jun 25, 2024
@elliot-100 elliot-100 self-assigned this Jun 25, 2024
@elliot-100 elliot-100 changed the title get_event() and get_group() fail with unexpected TypeError if no events/groups are available Spond.get_event() and Spond.get_group() fail with unexpected TypeError if no events/groups are available Jul 19, 2024
@elliot-100
Copy link
Collaborator Author

elliot-100 commented Sep 6, 2024

On closer inspection, what actually happens in above is that the JSON response is an authentication error from the server, which parses as a dict instead of expected list[dict].

Thus the error message: event in this case is actually a dict key str instead of expected dict.

I will look at the authentication code but I have to say I don't really understand it - it seems to handle AuthenticationError in two places, for example. I am not sure that mock_require_authentication() in tests actually works properly, either...

[Edit to add: the code as designed should be able to return None if no events/groups are available, so PR #151 to cover #147 is still valid... I think]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant