fix(auth): make plan and org fetches non-fatal, always persist auth#1898
Merged
richiemcilroy merged 2 commits intoJun 8, 2026
Merged
Conversation
…ith updated timestamp
Contributor
Author
|
@greptileai please re-review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Even after the org-fetch fix in #1896, auth still didn't persist on self-hosted because organizations_updated_at was never stamped when fetches failed, and hasCompleteOrganizationCache requires it to be set for signedIn() to return true.
Both plan and org fetches are now non-fatal. Whatever succeeds gets saved, and organizations_updated_at is always stamped at the end, so the UI sees a valid cache and stays signed in regardless of what the self-hosted server returns.
Confirmed working against https://demos.alphaomegateam.co/
Greptile Summary
This PR makes the
/api/desktop/planand/api/desktop/organizationsfetches non-fatal insideupdate_auth_plan, and ensuresSelf::setis always called so auth is persisted regardless of which fetches succeed or fail. The fix specifically targets self-hosted deployments where these endpoints may not exist.matchblock withtracing::warn!on any failure or non-success status, and only updatesauth.planon a valid 200 + parseable JSON response.organizations_updated_atwhenauth.organizationsis empty, which is the key unlock forsignedIn()to returntrueon self-hosted (where the org endpoint returns 404 and no prior cache exists).is_empty()guard on the error branch is a targeted improvement over unconditionally stamping the timestamp, but the cloud-vs-self-hosted ambiguity on a first login (empty cached orgs + transient failure) remains an open concern per the existing review thread.Confidence Score: 4/5
Safe to merge for self-hosted scenarios; the unresolved ambiguity around empty-org stamping on first login still applies to cloud deployments with transient failures.
The auth persistence logic is now correct for the self-hosted case. The is_empty() guard on the error branch reduces the blast radius compared to unconditional stamping, but on a first login against a cloud server where the org endpoint transiently returns an error, organizations_updated_at will still be stamped with an empty org list, leaving the UI in a signed-in-but-no-orgs state. No new functional regressions were introduced beyond what was already flagged in the prior review thread.
apps/desktop/src-tauri/src/auth.rs — specifically the error branch of the org fetch (lines 103–108) and the interaction with the frontend's hasCompleteOrganizationCache freshness check.
Important Files Changed
Reviews (2): Last reviewed commit: "fix(auth): only stamp org timestamp on f..." | Re-trigger Greptile