Skip to content

Add retry logic for folder creation confirmation#9

Open
arduoi wants to merge 1 commit into
keksiqc:mainfrom
arduoi:retry-create-folder
Open

Add retry logic for folder creation confirmation#9
arduoi wants to merge 1 commit into
keksiqc:mainfrom
arduoi:retry-create-folder

Conversation

@arduoi

@arduoi arduoi commented Jun 10, 2026

Copy link
Copy Markdown

Implement retry mechanism for folder visibility after creation

ControlD's API can be eventually consistent — after creating a folder via POST,
the subsequent GET request to retrieve the folder list may not include the newly
created folder immediately. This causes a spurious "Folder 'X' was not found
after creation" error.

This change adds a retry loop (up to 5 attempts with progressive 2s/4s/6s/8s delays)
when the folder isn't found in the response, fixing the race condition at its
source. After 5 failed attempts, it logs the error and returns None as before.

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of folder creation by implementing retry logic to handle API eventual consistency delays.

Implement retry mechanism for folder visibility after creation.
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 24c11d00-2b10-4c60-bfbd-89fd3fd208c1

📥 Commits

Reviewing files that changed from the base of the PR and between cae58b6 and 5babee4.

📒 Files selected for processing (1)
  • main.py

📝 Walkthrough

Walkthrough

The PR updates create_folder in main.py to handle eventual consistency in the Control-D API. After creating a folder, the function now retries up to 5 times with exponential backoff to retrieve the folder ID from the groups list, rather than performing a single immediate lookup. If unsuccessful after all retries, it logs an error and returns None.

Changes

Eventual Consistency Handling in Folder Creation

Layer / File(s) Summary
Retry logic with exponential backoff for folder creation
main.py
The create_folder function now performs up to 5 re-fetch attempts with increasing delays between retries to find the newly created folder ID in the groups list, falling back to error logging and None return if not found.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A folder springs forth from the API's hand,
But finds itself lost in consistency's land.
With patience and backoff, five times we wait,
Until the folder shows up—never too late! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: adding retry logic to handle folder creation confirmation issues in the Control-D API.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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