cassiopeia icon indicating copy to clipboard operation
cassiopeia copied to clipboard

Match in match history of a summoner that has changed names bug

Open gunaso opened this issue 4 years ago • 5 comments

When trying to load some information from matches from a match history from a summoner that changed names, the matches happened before the name was changed raises an exception in some stats.

import cassiopeia as cass
import arrow

if __name__ == '__main__':
    cass.apply_settings("settings\settingsNA.json")

    summoner = cass.get_summoner(name='Busio3')
    matchHistory = cass.core.match.MatchHistory(summoner=summoner, begin_time=arrow.get(1578657600), queues=[cass.data.Queue.ranked_solo_fives])

    for i, match in enumerate(matchHistory):
        if i > 234:
            for participant in match.participants:
                if participant.summoner.account_id == summoner.account_id:
                    print(str(i) + ": " + str(participant.team.win))

gunaso avatar Mar 31 '20 03:03 gunaso

I'm still not able to reproduce the issue. I paste this code and and get an error about cass.get_summoner not having a region, because I don't have your settings file, so I add region="NA" and the code works correctly.

Try disabling your settings file and instead providing a region to the cass.get_summoner function instead.

jjmaldonis avatar Apr 01 '20 00:04 jjmaldonis

These are my settings without the API key:

{
  "global": {
    "version_from_match": "patch",
    "default_region": "NA"
  },
  "plugins": {},
  "pipeline": {
    "SimpleKVDiskStore": {
      "package": "cassiopeia_diskstore",
      "path": "data/na/"
    },
    "DDragon": {},
    "RiotAPI": {
      "api_key": "",
      "limiting_share": 1.0,
      "request_error_handling": {
          "404": {
              "strategy": "throw"
          },
          "429": {
              "service": {
                  "strategy": "exponential_backoff",
                  "initial_backoff": 1.0,
                  "backoff_factor": 2.0,
                  "max_attempts": 4
              },
              "method": {
                  "strategy": "retry_from_headers",
                  "max_attempts": 5
              },
              "application": {
                  "strategy": "retry_from_headers",
                  "max_attempts": 5
              }
        },
        "500": {
            "strategy": "throw"
        },
        "503": {
          "strategy": "exponential_backoff",
          "initial_backoff": 1.0,
          "backoff_factor": 2.0,
          "max_attempts": 4
        },
        "timeout": {
            "strategy": "throw"
        },
        "403": {
            "strategy": "throw"
        }
      }
    }
  },
  "logging": {
    "print_calls": false,
    "print_riot_api_key": false,
    "default": "WARNING",
    "core": "WARNING"
  }
}

gunaso avatar Apr 01 '20 02:04 gunaso

Just tried without the settings that I was using and worked fine, so it seems like it has something to do with the settings that is messing up the search.

gunaso avatar Apr 01 '20 03:04 gunaso

Yes it is the "default_region": "NA" that is causing the "problem", and I put quotes around "problem" because now I realize what's going on. This is in fact intended functionality. The summoner must have changed regions to NA when their 234th game was played, so you're able to access their matches in NA up until those matches were in a different region.

By defining "default_region": "NA" we're saying that "unless I say otherwise, use region NA". In this case you haven't said that a different region should be used, so it defaults to NA, which is the wrong region for the match. When the request is made with the NA region rather than the correct region, a different match is returned by the API and things blow up -- causing an exception to be thrown, and this is indeed exceptional behavior.

If you want to access matches in a different region than NA, then try not using a default region in the summoner definition, or remove the default region from your settings file entirely.

Let's leave this issue open because there is probably a bug in there somewhere, but it's probably pretty deep and uncommon. I'd almost rather just remove the ability to set a default region entirely, because it's more hassle than savings since it adds undefined behavior to the equation.

jjmaldonis avatar Apr 01 '20 04:04 jjmaldonis

That is not the case for this account, this account was created in NA and hasn't switched regions in the past. All the games were played in the NA server

gunaso avatar Apr 01 '20 04:04 gunaso