Skip to content

Add retry logic to enrichSTRING_API for transient HTTP errors#15

Merged
veitveit merged 5 commits intomasterfrom
copilot/try-again-feature
Mar 26, 2026
Merged

Add retry logic to enrichSTRING_API for transient HTTP errors#15
veitveit merged 5 commits intomasterfrom
copilot/try-again-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

The STRING API can fail transiently (rate limits, server errors, gateway timeouts), causing enrichment analysis to fail with no recovery path.

Changes

  • R/WrapperFuncs.R: Added max_retries (default 3) and retry_delay (default 5s) parameters to enrichSTRING_API(). Wraps the httr::POST call in a repeat loop that retries on HTTP 429, 500, 502, 503, 504; sleeps between attempts; verbose mode logs each retry.

  • tests/testthat/test-enrichSTRING_API.R: Three new tests covering retry exhaustion, no-retry on non-retryable errors (e.g. 400), and success after transient failures — using local_mocked_bindings with explicit status-code sequences to avoid fragile call-count comparisons.

Usage

# Retry up to 5 times with 10s delay; default is max_retries=3, retry_delay=5
enrichSTRING_API(genes, max_retries = 5, retry_delay = 10)
Original prompt

Done, try again

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add retry functionality to handling errors Add retry logic to enrichSTRING_API for transient HTTP errors Mar 26, 2026
Copilot AI requested a review from veitveit March 26, 2026 06:30
@veitveit
Copy link
Copy Markdown
Collaborator

@copilot THere are still some faling tests (see your pull request), please investigate.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 26, 2026

@copilot THere are still some faling tests (see your pull request), please investigate.

Investigated the CI failures in commit 5ee89bf. Two root causes:

  1. runFuncEnrich() using shiny::validate() outside Shiny context (Ubuntu/macOS failures): When the STRING API returns no results in CI, validate(need(!is.null(x), "...")) threw a shiny.silent.error that propagated as an uncaught error in the vignette. Fixed by using stop() when outside a Shiny reactive domain, and validate() only within Shiny.

  2. Vignette not handling STRING API unavailability (Ubuntu/macOS failures): The vignette chunk calling runFuncEnrich() had no error handling. Fixed by wrapping it in tryCatch and making the visualization chunk conditional on the enrichment result being non-NULL.

The Windows failure (could not find function "run_fuzzy_cmeans") and oldrel-1 failure (ggtree build error) appear to be pre-existing infrastructure issues unrelated to this PR.

Copilot AI requested a review from veitveit March 26, 2026 08:48
@veitveit
Copy link
Copy Markdown
Collaborator

@copilot Still plenthy of failing CI runs.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 26, 2026

@copilot Still plenthy of failing CI runs.

Found and fixed the remaining CI failures in commit e202660. All three failing jobs (macOS, Ubuntu release, Ubuntu devel) had the same root cause: man/enrichSTRING_API.Rd was missing the max_retries and retry_delay parameters in its \usage{} and \arguments{} sections, causing R CMD check to fail with a "codoc mismatch" WARNING. Updated the .Rd file to match the function signature.

The Windows failure (could not find function "run_fuzzy_cmeans") and oldrel-1 failure (ggtree build error) are pre-existing infrastructure issues unrelated to this PR.

Copilot AI requested a review from veitveit March 26, 2026 09:53
@veitveit veitveit marked this pull request as ready for review March 26, 2026 11:55
@veitveit veitveit merged commit 6ded410 into master Mar 26, 2026
5 of 7 checks passed
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