Skip to content

Controls cache invalidation or persistance on errors#4945

Merged
sergeibbb merged 2 commits intomainfrom
4944-cache-auth-errors
Feb 26, 2026
Merged

Controls cache invalidation or persistance on errors#4945
sergeibbb merged 2 commits intomainfrom
4944-cache-auth-errors

Conversation

@sergeibbb
Copy link
Member

@sergeibbb sergeibbb commented Jan 30, 2026

Description

Solves #4942

Controls cache invalidation or persistence on errors.
The goal is to be able to preserve some types of errors in cache, to avoid retrieving the same failures repeatedly.

Be careful, because it makes #4943 more noticeable by preserving the cached Auth Error even if user re-connects. Workaround for user: reload the window. Probably we do not want to merge this PR until #4943 is done.

Background

Initially it's been done as part of #4731 but while revealing more and more nuances I decided to ship in smaller changes to make things reviewed and merged faster.

Checklist

  • I have followed the guidelines in the Contributing document
  • My changes follow the coding style of this project
  • My changes build without any errors or warnings
  • My changes have been formatted and linted
  • My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

@sergeibbb sergeibbb force-pushed the 4944-cache-auth-errors branch 2 times, most recently from a635ec7 to 811c35b Compare January 30, 2026 16:16
@sergeibbb sergeibbb force-pushed the 4944-cache-auth-errors branch from 811c35b to 81c5010 Compare January 30, 2026 16:17
@sergeibbb sergeibbb marked this pull request as ready for review January 30, 2026 16:24
@augmentcode
Copy link

augmentcode bot commented Jan 30, 2026

🤖 Augment PR Summary

Summary: This PR refines integration caching behavior to better control whether cached entries are invalidated or retained when requests fail.

Changes:

  • Extends cache callbacks to receive a CacheController, allowing callers to explicitly invalidate entries after async work completes
  • Adds an expireOnError option to CacheProvider to choose whether failed promises remove cached entries
  • Updates IntegrationBase.getCurrentAccount to invalidate cache on cancellations and non-auth errors, but to rethrow provider errors for callers to surface
  • Adjusts PR/issue cache wrapping to propagate the new controller through wrappers
  • Updates the changelog noting improved display of revoked-credential auth errors in Launchpad

Technical Notes: Failed-promise caching behavior is now configurable via expireOnError and explicit invalidation.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@sergeibbb sergeibbb linked an issue Feb 12, 2026 that may be closed by this pull request
@sergeibbb sergeibbb force-pushed the 4944-cache-auth-errors branch 2 times, most recently from 27a493c to 0cf4471 Compare February 12, 2026 14:44
Copy link
Contributor

@ramin-t ramin-t left a comment

Choose a reason for hiding this comment

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

Just wanted to double-check with you on something I noticed

Comment on lines +625 to +626
// Re-throw to the caller
throw ex;
Copy link
Contributor

Choose a reason for hiding this comment

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

We are throwing the error up the chain now on every error except for cancellations, where before these changes we would swallow the error and return undefined.

Just want to make sure this is intended and we have considered side effects of this logic change.

Copy link
Member Author

Choose a reason for hiding this comment

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

@axosoft-ramint

Yes — it's intended. Actually the main goal of the current PR is being able to throw while keep caching the result (even an error result).

The outcome is the following:

  • Once the undefined was cached, the Launchpad stopped indicating that there is a problem with GitLab authentication token: it just showed an empty list. We wanted to throw, but before these changes the error result was not cached so we would hit the same endpoint again and again, receiving the same problematic result.
  • Now, when it throws, it will display the note that an error has happened. Even if it's some other (non-auth) error, it seems useful to keep the clarity for user and indicate that part of PRs is not shown due to an error.

@sergeibbb sergeibbb force-pushed the 4944-cache-auth-errors branch 3 times, most recently from 49b4888 to 68ec239 Compare February 23, 2026 18:26
@sergeibbb sergeibbb force-pushed the 4944-cache-auth-errors branch from 68ec239 to c6ccc34 Compare February 24, 2026 16:07
Also add an additional check for setting resolved values in possible race condition.

The `set` method now returns the promise associated with an asynchronous cache value. This enables the `get` method to reliably attach a `finally` handler for cache invalidation directly to the promise managing the cache item's eventual resolution.

This change also introduces a check within the `set` method's promise resolution callback to prevent stale updates. If a cache entry has been modified or removed while an asynchronous value was pending, the original promise's resolution will no longer overwrite the current cache state. This enhances cache consistency and robustness against race conditions.

Error handling for `expireOnError` is also properly integrated into the returned promise chain.

(#4942, #4944)
@sergeibbb sergeibbb force-pushed the 4944-cache-auth-errors branch from c6ccc34 to aa01d59 Compare February 26, 2026 14:08
Copy link
Contributor

@ramin-t ramin-t left a comment

Choose a reason for hiding this comment

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

Thanks for the explanation!

@sergeibbb sergeibbb merged commit 39c640d into main Feb 26, 2026
6 checks passed
@sergeibbb sergeibbb deleted the 4944-cache-auth-errors branch February 26, 2026 15:29
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.

4942: swallowing of an Authentication Error

3 participants