Skip to content

Implement rate-limiting countermeasures - #30

Open
Jan-Hendrik Peters (nyanhp) wants to merge 2 commits into
PSModule:mainfrom
nyanhp:feature/throttling
Open

Jan-Hendrik Peters (nyanhp) wants to merge 2 commits into
PSModule:mainfrom
nyanhp:feature/throttling

Conversation

@nyanhp

Copy link
Copy Markdown

Confluence enacts a rate limit, which can be countered using the values supplied in their response headers on receiving an HTTP 429 error. This PR implements rate-limiting countermeasures by sleeping for the amount of time specified in the Retry-After header.


Technical details

Implementation approach: Evaluate HTTP 429, use values supplied by Atlassian, observe ~400 pages get created
Issue-plan progress: ?
Standards alignment: The new code adheres to PowerShell best practices and the code style found in this project
Convergence Sweep: I don't know what that means

Relevant issues (or links)

Copilot AI balanced review requested due to automatic review settings October 26, 2026 14:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The near-limit check cannot convert array-valued headers, causing errors even on successful requests.

1 open issue
What changed in this PR

This PR adds rate-limit handling to the shared Confluence REST helper to reduce throttling and retry requests rejected with HTTP 429.

Changes:

  • Adds a 500 ms delay when the near-limit response header is true.
  • Waits for the Retry-After interval before retrying a throttled request once.
File Description
src/​functions/​public/​API/​Invoke-ConfluenceRestMethod.ps1 Adds near-limit delays and HTTP 429 retry handling.

Review effort: Balanced

Comment thread src/functions/public/API/Invoke-ConfluenceRestMethod.ps1 Outdated
…header string arrays correctly'

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 26, 2026 15:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Consecutive HTTP 429 responses still terminate operations because the retry bypasses further rate-limit handling.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Retry repeated 429 responses using each Retry-After value

src/​functions/​public/​API/​Invoke-ConfluenceRestMethod.ps1:190

If the retry also returns HTTP 429, execution goes straight to the error handler without waiting for that response's Retry-After value. For example, a 429 → 429 → 200 sequence aborts after the second response, so sustained throttling still interrupts bulk page creation. Use a bounded retry loop that reads the updated header on each 429 and throws when the retry budget is exhausted or a non-retryable error occurs.

1 resolved since last review

Review effort: Balanced

This branch has not been deployed

No deployments
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.

2 participants