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

TypeError When Scoring Decaying Map Challenge #259

Open
sentry-io bot opened this issue Mar 3, 2022 · 2 comments
Open

TypeError When Scoring Decaying Map Challenge #259

sentry-io bot opened this issue Mar 3, 2022 · 2 comments
Labels
bug Something isn't working priority: low size: large

Comments

@sentry-io
Copy link

sentry-io bot commented Mar 3, 2022

Sentry Issue: BACKEND-4D

TypeError: unsupported operand type(s) for -: 'int' and 'str'
(9 additional frame(s) were not displayed)
...
  File "backend/exception_handler.py", line 50, in handle_exception
    raise exc
  File "rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "challenge/views.py", line 309, in post
    solve = challenge.points_plugin.score(user, team, flag, solve_set.filter(correct=True))
  File "plugins/points/base.py", line 29, in score
    points = self.get_points(team, flag, solves.count())
  File "plugins/points/decay.py", line 17, in get_points
    return int(round(min_points + ((challenge.score - min_points) * (decay_constant ** max(solves - 1, 0)))))
@thebeanogamer thebeanogamer added the bug Something isn't working label Mar 3, 2022
@thebeanogamer
Copy link
Member

When the user submits a change to the flag metadata (for example changing the radius of a map challenge), the min_points and decay_constant fields are getting written as empty string rather than the expected behavior of them being excluded.

 'flag_metadata': {'radius': 1,
  'location': [0, 0],
  'min_points': '',
  'decay_constant': ''},

That means that these lines collect empty string, causing the type error

decay_constant = challenge.flag_metadata.get("decay_constant", 0.99)
min_points = challenge.flag_metadata.get("min_points", 100)

Either we need to make these ignore empty string, or not make those fields get written unnecessarily (or move this out of flag_metadata).

@jchristgit
Copy link
Collaborator

not make those fields get written unnecessarily

I'm a fan of this approach personally, then if we later add other parts we don't need to adjust there

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

No branches or pull requests

3 participants