alopezlago / QuizBowlDiscordScoreTracker

MIT License
6 stars 4 forks source link

"ColumnNumber must be >= 1" when trying to set rosters #86

Closed alopezlago closed 3 years ago

alopezlago commented 3 years ago

During a tournament, a director tried to set the rosters for TJ Sheets from their team roles, but the bot would either not respond or say that it didn't understand the URL. For the first case, it appears that we hit this error

Discord.Commands.CommandException: Error occurred executing "setRostersForTJ" ---> System.ArgumentOutOfRangeException: columnNumber must be >= 1 (Parameter 'columnNumber') at QuizBowlDiscordScoreTracker.Scoresheet.SpreadsheetColumn..ctor(Int32 columnNumber) in C:\Users\Alejandro\Documents\Visual Studio 2017\Projects\QuizBowlDiscordScoreTracker\QuizBowlDiscordScoreTracker\Scoresheet\SpreadsheetColumn.cs:line 24 at QuizBowlDiscordScoreTracker.Scoresheet.SpreadsheetColumn.op_Addition(SpreadsheetColumn column, Int32 value) in C:\Users\Alejandro\Documents\Visual Studio 2017\Projects\QuizBowlDiscordScoreTracker\QuizBowlDiscordScoreTracker\Scoresheet\SpreadsheetColumn.cs:line 45 at QuizBowlDiscordScoreTracker.Scoresheet.BaseGoogleSheetsGenerator.CreateUpdateCellsAlongRowRequest[T](String sheetName, SpreadsheetColumn column, Int32 rowNumber, IEnumerable1 values) in C:\Users\Alejandro\Documents\Visual Studio 2017\Projects\QuizBowlDiscordScoreTracker\QuizBowlDiscordScoreTracker\Scoresheet\BaseGoogleSheetsGenerator.cs:line 283 at QuizBowlDiscordScoreTracker.Scoresheet.TJSheetsGenerator.GetUpdateRangesForRoster(IReadOnlyDictionary2 teamIdToNames, IEnumerable`1 groupings) in C:\Users\Alejandro\Documents\Visual Studio 2017\Projects\QuizBowlDiscordScoreTracker\QuizBowlDiscordScoreTracker\Scoresheet\TJSheetsGenerator.cs:line 166 at QuizBowlDiscordScoreTracker.Scoresheet.BaseGoogleSheetsGenerator.TryUpdateRosters(ITeamManager teamManager, Uri sheetsUri) in C:\Users\Alejandro\Documents\Visual Studio 2017\Projects\QuizBowlDiscordScoreTracker\QuizBowlDiscordScoreTracker\Scoresheet\BaseGoogleSheetsGenerator.cs:line 188 at QuizBowlDiscordScoreTracker.Commands.AdminCommandHandler.SetRostersFromRolesForSheets(String sheetsUrl, GoogleSheetsType type) in C:\Users\Alejandro\Documents\Visual Studio 2017\Projects\QuizBowlDiscordScoreTracker\QuizBowlDiscordScoreTracker\Commands\AdminCommandHandler.cs:line 389 at Discord.Commands.ModuleClassBuilder.<>c__DisplayClass6_0.<g__ExecuteCallback|0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Discord.Commands.CommandInfo.ExecuteInternalAsync(ICommandContext context, Object[] args, IServiceProvider services) --- End of inner exception stack trace ---

This means that we tried accessing a non-existent column, likely column 0 instead of column 1 (A).

alopezlago commented 3 years ago

Looking at the code, this could potentially happen if it couldn't find any teams to export, since it would adjust the number of columns it needs to be -1.

alopezlago commented 3 years ago

Verified that this can happen if you call !setRostersForTJ with 0 teams.

alopezlago commented 3 years ago

This was run in a bot + admin only channel, so it would be good to check if this happened because the roles didn't have access to the channel. Seems like the most likely cause.

alopezlago commented 3 years ago

Fixed by #88