Skip to content

Fetch cards using boards API with pagination rather than the .json backup endpoint#63

Open
mickzijdel wants to merge 2 commits intoGSGBen:mainfrom
mickzijdel:pagination-for-fetching-cards
Open

Fetch cards using boards API with pagination rather than the .json backup endpoint#63
mickzijdel wants to merge 2 commits intoGSGBen:mainfrom
mickzijdel:pagination-for-fetching-cards

Conversation

@mickzijdel
Copy link

Changes

  1. Fetch the cards using the board API
  2. Create a temporary list to hold orphaned cards

Context

I wanted to backup my Trello boards but for one board I got the following timeout error:

Unhandled exception. System.Net.Http.HttpRequestException: Response status code does not indicate success: 449 (Unknown).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at GoldenSyrupGames.T2MD.Cli.ProcessTrelloBoardAsync(TrelloApiBoardModel trelloApiBoard, CliOptions options, Dictionary`2 duplicateBoardSuffixes) in /path/to/repo/T2MDCli/Cli.cs:line 475
   at GoldenSyrupGames.T2MD.Cli.RunAsync(CliOptions options) in /path/to/repo/t2md-main/T2MDCli/Cli.cs:line 234
   at GoldenSyrupGames.T2MD.Cli.Main(String[] args) in /path/to/repo/T2MDCli/Cli.cs:line 47
   at GoldenSyrupGames.T2MD.Cli.<Main>(String[] args)

and when just fetching the failing board, I got this error:

Unhandled exception. System.Net.Http.HttpRequestException: Response status code does not indicate success: 504 (Gateway Timeout).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at GoldenSyrupGames.T2MD.Cli.ProcessTrelloBoardAsync(TrelloApiBoardModel trelloApiBoard, CliOptions options, Dictionary`2 duplicateBoardSuffixes) in /path/to/repo/T2MDCli/Cli.cs:line 333
   at GoldenSyrupGames.T2MD.Cli.RunAsync(CliOptions options) in /path/to/repo/t2md-main/T2MDCli/Cli.cs:line 234
   at GoldenSyrupGames.T2MD.Cli.Main(String[] args) in /path/to/repo/t2md-main/T2MDCli/Cli.cs:line 47
   at GoldenSyrupGames.T2MD.Cli.<Main>(String[] args)
Aborted (core dumped)

I couldn't figure out what it was, but after navigating to the URL manually, I got the following error:

"API::TooManyCardsRequested: Requested too many cards, please limit\n at checkLimits (/opt/service/app/api/1/mixins/cardsMixinFactory.js:53:31)\n at Object.fx (/opt/service/app/api/1/mixins/cardsMixinFactory.js:718:25)\n at handleRequest (/opt/service/app/components/handler/handleRequest.js:134:16)\n at addPaths (/opt/service/app/components/api.js:294:30)\n at getPathDependencies (/opt/service/app/components/transformer.js:111:9)\n at Function.all (<anonymous>:null:null)\n at transformMany (/opt/service/app/components/transformer.js:195:51)\n at Object.transformOne (/opt/service/app/components/transformer.js:222:25)\n at Object.fx (/opt/service/app/api/1/board/controller/getBoardController.js:372:34)\n at handleRequest (/opt/service/app/components/handler/handleRequest.js:134:16)\n at runHandlerWithRequest (/opt/service/app/components/handler/runHandlerWithRequest.js:40:24)\n"

I fed Claude the API docs and asked it to modify the code for me so that it would fetch all the cards in the board with pagination in batches of a 1000 (the limit). After a few attempts, it came up with this code, which solved the issue and I have now backed up the board.

I do not have full project context to know if these changes make sense (maybe they should be put behind a flag?) but I wanted to provide it to you in case you can easily incorporate it.

@mickzijdel mickzijdel marked this pull request as ready for review May 15, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant