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

[Bug]: (Enum.EmptyError) empty error during balance_battle request #430

Open
L-e-x-o-n opened this issue Aug 26, 2024 · 6 comments
Open
Assignees
Labels
bug Something isn't working medium priority

Comments

@L-e-x-o-n
Copy link
Collaborator

L-e-x-o-n commented Aug 26, 2024

Describe the Bug

Logs:

Request: POST /teiserver/api/spads/balance_battle
** (exit) an exception was raised:
    ** (Enum.EmptyError) empty error
        (elixir 1.14.5) lib/enum.ex:1855: anonymous fn/0 in Enum.max/1
        (teiserver 0.1.0) lib/teiserver_web/controllers/api/spads_controller.ex:164: TeiserverWeb.API.SpadsController.balance_battle/2
        (teiserver 0.1.0) lib/teiserver_web/controllers/api/spads_controller.ex:1: TeiserverWeb.API.SpadsController.action/2
        (teiserver 0.1.0) lib/teiserver_web/controllers/api/spads_controller.ex:1: TeiserverWeb.API.SpadsController.phoenix_controller_pipeline/2
        (phoenix 1.7.6) lib/phoenix/router.ex:430: Phoenix.Router.__call__/5
        (teiserver 0.1.0) lib/teiserver_web/endpoint.ex:1: TeiserverWeb.Endpoint.plug_builder_call/2
        (teiserver 0.1.0) lib/teiserver_web/endpoint.ex:1: TeiserverWeb.Endpoint.call/2
        (plug_cowboy 2.6.1) lib/plug/cowboy/handler.ex:11: Plug.Cowboy.Handler.init/2
          team_size =
            balance_result.team_sizes
            |> Map.values()
            |> Enum.max()

It seems team_sizes might be empty.

Reproduce the bug

Unfortunately the logs don't contain any other details. Don't know the team count, team size or balance algorithm used. There are only 2 such errors recently in logs so I think it's probably some edge case.

Screenshots

No response

Additional context

No response

@L-e-x-o-n L-e-x-o-n added bug Something isn't working medium priority labels Aug 26, 2024
@jauggy
Copy link
Member

jauggy commented Aug 26, 2024

@L-e-x-o-n you can assign to me.

@jauggy
Copy link
Member

jauggy commented Aug 30, 2024

So I had an idea to press balance as spec when there are no players - but it won't even let you do that.

@jauggy
Copy link
Member

jauggy commented Sep 5, 2024

@L-e-x-o-n where are the logs stored? Want to try deliberately raising errors on my local environment.

@L-e-x-o-n
Copy link
Collaborator Author

When running it locally over WSL? Not sure if they are saved, but wouldn't you be able to see them when starting the server with mix phx.server?

@jauggy
Copy link
Member

jauggy commented Sep 19, 2024

Screenshot 2024-09-20 at 8 56 59 AM

Interesting that Enum.max generates that error when array is empty but not when array is nil

@jauggy
Copy link
Member

jauggy commented Sep 19, 2024

Screenshot 2024-09-20 at 8 59 26 AM
Also get that error with empty map which is the default for team_sizes

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

No branches or pull requests

2 participants