Skip to content

Commit 7f680c5

Browse files
author
Lasim
committed
fix(gateway): simplify error handling in login command
1 parent e7fde8c commit 7f680c5

File tree

7 files changed

+25
-20
lines changed

7 files changed

+25
-20
lines changed

services/gateway/src/commands/login.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function registerLoginCommand(program: Command) {
6060
spinner.succeed('Credentials stored securely');
6161
console.log(chalk.yellow('⚠️ No default team found - you may need to select a team manually'));
6262
}
63-
} catch (teamError) {
63+
} catch {
6464
spinner.succeed('Credentials stored securely');
6565
console.log(chalk.yellow('⚠️ Could not auto-select default team - you can select one later'));
6666
}

services/gateway/src/core/auth/api-client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import fetch from 'node-fetch';
2-
import { StoredCredentials, UserInfo, TokenInfo, Team, TeamsResponse, AuthError, AuthenticationError } from '../../types/auth';
3+
import { StoredCredentials, UserInfo, TokenInfo, Team, AuthError, AuthenticationError } from '../../types/auth';
34
import { buildAuthConfig } from '../../utils/auth-config';
45

56
export class DeployStackAPI {
@@ -128,7 +129,7 @@ export class DeployStackAPI {
128129
} else {
129130
errorData = { error: await response.text() };
130131
}
131-
} catch (parseError) {
132+
} catch {
132133
errorData = { error: 'Unknown error' };
133134
}
134135

services/gateway/src/core/auth/browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class BrowserManager {
6060
try {
6161
await this.openBrowser(url);
6262
console.log(chalk.green('🌐 Opened browser to authorization page'));
63-
} catch (error) {
63+
} catch {
6464
this.displayUrlForManualOpening(url);
6565
}
6666
}

services/gateway/src/core/auth/oauth.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class OAuth2Client {
7070
'Authentication timeout - no response received within the specified time'
7171
)), timeout)
7272
)
73+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7374
]) as any;
7475

7576
if (callbackResult.error) {
@@ -173,6 +174,7 @@ export class OAuth2Client {
173174
});
174175

175176
if (!response.ok) {
177+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
176178
const errorData = await response.json().catch(() => ({ error: 'unknown_error' })) as any;
177179
throw new AuthenticationError(
178180
AuthError.INVALID_GRANT,
@@ -250,6 +252,7 @@ export class OAuth2Client {
250252
});
251253

252254
if (!response.ok) {
255+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
253256
const errorData = await response.json().catch(() => ({ error: 'unknown_error' })) as any;
254257
throw new AuthenticationError(
255258
AuthError.INVALID_GRANT,

services/gateway/src/core/auth/storage.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { keyring } from '@zowe/secrets-for-zowe-sdk';
1+
import { keyring } from '@zowe/secrets-for-zowe-sdk';
22
import { writeFileSync, readFileSync, existsSync, unlinkSync } from 'fs';
33
import { join } from 'path';
44
import { homedir } from 'os';
@@ -70,7 +70,7 @@ export class CredentialStorage {
7070
} else {
7171
// REMOVED: console.log('⚠ No credentials found in encrypted file');
7272
}
73-
} catch (error) {
73+
} catch {
7474
// REMOVED: console.log('❌ Error reading encrypted file:', (error as Error)?.message);
7575
}
7676

@@ -90,15 +90,15 @@ export class CredentialStorage {
9090
// REMOVED: console.log('✓ Found credentials in OS keychain for:', account);
9191
return credentials;
9292
}
93-
} catch (error) {
93+
} catch {
9494
// REMOVED: console.log('⚠ Failed to retrieve credentials for account:', account);
9595
continue;
9696
}
9797
}
9898
} else {
9999
// REMOVED: console.log('⚠ No accounts found in keychain');
100100
}
101-
} catch (error) {
101+
} catch {
102102
// REMOVED: console.log('❌ Error accessing keychain:', (error as Error)?.message);
103103
}
104104

@@ -152,13 +152,13 @@ export class CredentialStorage {
152152
for (const account of accounts) {
153153
try {
154154
await keyring.deletePassword(this.serviceName, account);
155-
} catch (error) {
155+
} catch {
156156
// Continue clearing other accounts even if one fails
157157
}
158158
}
159159
await this.clearAccountsList();
160160
}
161-
} catch (error) {
161+
} catch {
162162
// Continue to clear encrypted file even if keychain fails
163163
}
164164

@@ -183,7 +183,7 @@ export class CredentialStorage {
183183
const buffer = 5 * 60 * 1000; // 5 minutes
184184

185185
return expiresAt > (now + buffer);
186-
} catch (error) {
186+
} catch {
187187
return false;
188188
}
189189
}
@@ -199,7 +199,7 @@ export class CredentialStorage {
199199
const accounts = JSON.parse(data);
200200
return Array.isArray(accounts) ? accounts : [];
201201
}
202-
} catch (error) {
202+
} catch {
203203
// If we can't read the accounts file, return empty array
204204
}
205205
return [];
@@ -215,7 +215,7 @@ export class CredentialStorage {
215215
const { mkdirSync } = await import('fs');
216216
try {
217217
mkdirSync(this.fallbackDir, { recursive: true });
218-
} catch (error) {
218+
} catch {
219219
// Directory might already exist
220220
}
221221

@@ -241,7 +241,7 @@ export class CredentialStorage {
241241
if (filtered.length !== accounts.length) {
242242
writeFileSync(this.accountsFile, JSON.stringify(filtered, null, 2));
243243
}
244-
} catch (error) {
244+
} catch {
245245
// Non-critical error, don't throw
246246
}
247247
}
@@ -254,7 +254,7 @@ export class CredentialStorage {
254254
if (existsSync(this.accountsFile)) {
255255
unlinkSync(this.accountsFile);
256256
}
257-
} catch (error) {
257+
} catch {
258258
// Non-critical error, don't throw
259259
}
260260
}
@@ -269,7 +269,7 @@ export class CredentialStorage {
269269
const { mkdirSync } = await import('fs');
270270
try {
271271
mkdirSync(this.fallbackDir, { recursive: true });
272-
} catch (error) {
272+
} catch {
273273
// Directory might already exist
274274
}
275275

@@ -311,11 +311,11 @@ export class CredentialStorage {
311311
decrypted += decipher.final('utf8');
312312

313313
return JSON.parse(decrypted);
314-
} catch (error) {
314+
} catch {
315315
// If we can't decrypt, the file might be corrupted
316316
try {
317317
unlinkSync(this.fallbackFile);
318-
} catch (unlinkError) {
318+
} catch {
319319
// Ignore unlink errors
320320
}
321321
return null;
@@ -330,7 +330,7 @@ export class CredentialStorage {
330330
if (existsSync(this.fallbackFile)) {
331331
unlinkSync(this.fallbackFile);
332332
}
333-
} catch (error) {
333+
} catch {
334334
// Ignore errors when clearing
335335
}
336336
}

services/gateway/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env node
22

33
import { Command } from 'commander';
4-
import chalk from 'chalk';
54
import { getVersionString } from './config/version';
65
import {
76
registerLoginCommand,

services/gateway/src/types/mcp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ export interface MCPServer {
88
env?: Record<string, string>;
99
}
1010

11+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
1112
export interface MCPRequest {
1213
// Placeholder for MCP request types
1314
}
1415

16+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
1517
export interface MCPResponse {
1618
// Placeholder for MCP response types
1719
}

0 commit comments

Comments
 (0)