-
Notifications
You must be signed in to change notification settings - Fork 2
PROD-89: Early auth/GUID failure detection #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AaronAgility
wants to merge
4
commits into
latest-beta
Choose a base branch
from
PROD-89/early-auth-failure-detection
base: latest-beta
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -399,6 +399,7 @@ export class Auth { | |
| // Step 3: Get API keys for all GUIDs | ||
| const allGuids = [...state.sourceGuid, ...state.targetGuid]; | ||
| state.apiKeys = []; | ||
| const failedGuids: string[] = []; | ||
|
|
||
| for (const guid of allGuids) { | ||
| if (guid) { | ||
|
|
@@ -408,11 +409,21 @@ export class Auth { | |
|
|
||
| state.apiKeys.push({ guid, previewKey, fetchKey }); | ||
| } catch (error) { | ||
| console.log(ansiColors.yellow(`Warning: Could not get keys for GUID ${guid}: ${error.message}`)); | ||
| failedGuids.push(guid); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // If any GUIDs failed key retrieval, this is almost certainly an auth or GUID problem | ||
| if (failedGuids.length > 0) { | ||
| console.log(ansiColors.red(`\nError: Failed to retrieve API keys for one or more specified GUIDs.`)); | ||
| console.log(ansiColors.red(`This usually means either:`)); | ||
| console.log(ansiColors.red(` 1. Your authentication has expired — run 'agility login' to re-authenticate`)); | ||
| console.log(ansiColors.red(` 2. The GUID(s) are incorrect — verify your --sourceGuid / --targetGuid values`)); | ||
| console.log(ansiColors.red(` 3. Your account does not have access to these instances\n`)); | ||
| return false; | ||
| } | ||
|
|
||
| // Step 4: Set up UI mode in state | ||
| state.useHeadless = state.headless; // headless takes precedence | ||
| state.useVerbose = !state.useHeadless && state.verbose; | ||
|
|
@@ -524,17 +535,35 @@ export class Auth { | |
|
|
||
|
|
||
| } catch (error) { | ||
| console.log(ansiColors.yellow(`Note: Could not auto-detect locales: ${error.message}`)); | ||
| state.availableLocales = ["en-us"]; // Fallback to default | ||
|
|
||
| // Create fallback mapping for all GUIDs | ||
| const fallbackLocales = state.locale.length > 0 ? [state.locale[0]] : ["en-us"]; | ||
| for (const guid of allGuids) { | ||
| if (guid) { | ||
| state.guidLocaleMap.set(guid, fallbackLocales); | ||
| // If we also failed to get keys for any GUIDs, this is likely an auth/GUID problem — fail fast | ||
| // This should never happen, but just in case | ||
| if (failedGuids.length > 0) { | ||
| console.log(ansiColors.red(`Error: Unable to retrieve locales, and API key retrieval also failed.`)); | ||
| console.log(ansiColors.red(`This strongly indicates an authentication or GUID configuration problem.`)); | ||
| console.log(ansiColors.red(` - Run 'agility login' to re-authenticate`)); | ||
| console.log(ansiColors.red(` - Verify your --sourceGuid / --targetGuid values are correct\n`)); | ||
| return false; | ||
| } | ||
|
|
||
| // Keys succeeded but locales failed — could be a transient issue, fall back gracefully | ||
| console.log(ansiColors.yellow(`Warning: Could not auto-detect locales: ${error.message}`)); | ||
| if (state.locale.length > 0) { | ||
| // User specified locales explicitly, use those | ||
| const guidLocaleMap = new Map<string, string[]>(); | ||
| for (const guid of allGuids) { | ||
| if (guid) { | ||
| guidLocaleMap.set(guid, state.locale); | ||
| } | ||
| } | ||
| state.guidLocaleMap = guidLocaleMap; | ||
| state.availableLocales = state.locale; | ||
| console.log(`📝 Using user-specified locales: ${state.locale.join(", ")}`); | ||
| } else { | ||
| // No explicit locales and auto-detect failed — can't safely assume en-us | ||
| console.log(ansiColors.red(`Error: Could not detect available locales and no --locale flag was provided.`)); | ||
| console.log(ansiColors.red(`Please specify locales explicitly with --locale (e.g., --locale en-us)\n`)); | ||
| return false; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously we had a fallback into en-us, but if those locales don't exist, the sync cascades into failures. |
||
| } | ||
| console.log(`📝 Using fallback mapping: all GUIDs → ${fallbackLocales.join(", ")}`); | ||
| } | ||
| } | ||
|
|
||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kick out early, previously was cascading failures into SDK calls.