Skip to content

Commit 5567cb3

Browse files
review comment fixes
1 parent 3a28c37 commit 5567cb3

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

packages/code-analyzer-apexguru-engine/src/services/ApexGuruAuthService.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ export class ApexGuruAuthService {
3232
async initialize(config: AuthConfig): Promise<void> {
3333
// Method 1: SF CLI org (alias or username) via --target-org flag
3434
if (config.targetOrg) {
35+
this.emitLogEvent(LogLevel.Fine, `Authenticating with org: ${config.targetOrg}`);
3536
try {
3637
const org = await Org.create({ aliasOrUsername: config.targetOrg });
3738
this.connection = org.getConnection();
39+
this.emitLogEvent(LogLevel.Fine, `Successfully authenticated to org`);
3840
return;
39-
} catch (_err) {
41+
} catch (err) {
42+
const errorMessage = err instanceof Error ? err.message : String(err);
43+
this.emitLogEvent(LogLevel.Error, `Failed to authenticate with org '${config.targetOrg}': ${errorMessage}`);
4044
throw new Error(
4145
`Failed to authenticate with org '${config.targetOrg}'. ` +
4246
'Please verify the org alias/username and ensure you are authenticated:\n' +
@@ -47,10 +51,14 @@ export class ApexGuruAuthService {
4751
}
4852

4953
// Method 2: SF CLI default org (fallback)
54+
this.emitLogEvent(LogLevel.Fine, 'No target org specified, using default org');
5055
try {
5156
const org = await Org.create({});
5257
this.connection = org.getConnection();
53-
} catch (_err) {
58+
this.emitLogEvent(LogLevel.Fine, 'Successfully authenticated to default org');
59+
} catch (err) {
60+
const errorMessage = err instanceof Error ? err.message : String(err);
61+
this.emitLogEvent(LogLevel.Error, `Failed to authenticate: No default org found: ${errorMessage}`);
5462
throw new Error(
5563
'No default org found. Please either:\n' +
5664
' 1. Set a default org: sf config set target-org <org-alias>\n' +

packages/code-analyzer-apexguru-engine/src/types/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,15 @@ export type ApexGuruSuggestion = {
8989
message: string; // Code suggestion
9090
};
9191

92+
/**
93+
* Response from the Org JWT minting endpoint (POST /ide/auth)
94+
* Used to authenticate against the SFAP ApexGuru API
95+
*/
9296
export type OrgJwtResponse = {
97+
/** The minted Org JWT token */
9398
jwt: string;
99+
100+
/** Optional message from the auth endpoint (e.g., error details) */
94101
message?: string | null;
95102
};
96103

0 commit comments

Comments
 (0)