Skip to content

Commit 349ecba

Browse files
authored
Merge pull request #2257 from contentstack/fix/DX-3458-error-msg-improve
improved error messages
2 parents 97cd57e + 77b5110 commit 349ecba

File tree

137 files changed

+1049
-1085
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+1049
-1085
lines changed

.talismanrc

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ fileignoreconfig:
141141
checksum: 93bdd99ee566fd38545b38a8b528947af1d42a31908aca85e2cb221e39a5b6cc
142142
- filename: packages/contentstack-export/test/unit/export/modules/stack.test.ts
143143
checksum: bb0f20845d85fd56197f1a8c67b8f71c57dcd1836ed9cfd86d1f49f41e84d3a0
144-
- filename: packages/contentstack-export/test/unit/export/modules/taxonomies.test.ts
145-
checksum: 5b1d2ba5ec9100fd6174e9c6771b7e49c93a09fa2d6aedadd338e56bc3e3610f
146144
- filename: packages/contentstack-export/test/unit/export/modules/custom-roles.test.ts
147145
checksum: 39f0166a8030ee8f504301f3a42cc71b46ddc027189b90029ef19800b79a46e5
148146
- filename: packages/contentstack-export/test/unit/export/modules/workflows.test.ts
@@ -179,16 +177,6 @@ fileignoreconfig:
179177
checksum: a5cd371d7f327c083027da4157b3c5b4df548f2c2c3ad6193aa133031994252e
180178
- filename: packages/contentstack-import/test/unit/utils/common-helper.test.ts
181179
checksum: 61b3cfe0c0571dcc366e372990e3c11ced2b49703ac88155110d33897e58ca5d
182-
- filename: packages/contentstack-import/test/unit/import/module-importer.test.ts
183-
checksum: aa265917b806286c8d4d1d3f422cf5d6736a0cf6a5f50f2e9c04ec0f81eee376
184-
- filename: packages/contentstack-export/test/unit/utils/interactive.test.ts
185-
checksum: b619744ebba28dbafe3a0e65781a61a6823ccaa3eb84e2b380a323c105324c1a
186-
- filename: packages/contentstack-import/test/unit/import/modules/index.test.ts
187-
checksum: aab773ccbe05b990a4b934396ee2fcd2a780e7d886d080740cfddd8a4d4f73f7
188-
- filename: packages/contentstack-import/test/unit/import/modules/personalize.test.ts
189-
checksum: ea4140a1516630fbfcdd61c4fe216414b733b4df2410b5d090d58ab1a22e7dbf
190-
- filename: packages/contentstack-import/test/unit/import/modules/variant-entries.test.ts
191-
checksum: abcc2ce0b305afb655eb46a1652b3d9e807a2a2e0eef1caeb16c8ae83af4f1a1
192180
- filename: packages/contentstack-import/test/unit/utils/import-path-resolver.test.ts
193181
checksum: 05436c24619b2d79b51eda9ce9a338182cc69b078ede60d310bfd55a62db8369
194182
- filename: packages/contentstack-import/test/unit/utils/interactive.test.ts

package-lock.json

Lines changed: 293 additions & 325 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-auth/src/commands/auth/login.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ export default class LoginCommand extends BaseCommand<typeof LoginCommand> {
5555
log.debug('LoginCommand run method started', this.contextDetails);
5656

5757
try {
58-
log.debug('Initializing management API client', this.contextDetails);
58+
log.debug('Initializing the Management API client.', this.contextDetails);
5959
const managementAPIClient = await managementSDKClient({ host: this.cmaHost, skipTokenValidity: true });
60-
log.debug('Management API client initialized successfully', this.contextDetails);
60+
log.debug('Management API client initialized successfully.', this.contextDetails);
6161

6262
const { flags: loginFlags } = await this.parse(LoginCommand);
63-
log.debug('Token add flags parsed', { ...this.contextDetails, flags: loginFlags });
63+
log.debug('Token add flags parsed.', { ...this.contextDetails, flags: loginFlags });
6464

6565
authHandler.client = managementAPIClient;
6666
log.debug('Auth handler client set', this.contextDetails);
@@ -86,7 +86,7 @@ export default class LoginCommand extends BaseCommand<typeof LoginCommand> {
8686
await this.login(username, password);
8787
}
8888
} catch (error) {
89-
log.debug('Login command failed', {
89+
log.debug('Login failed.', {
9090
...this.contextDetails,
9191
error,
9292
});
@@ -116,26 +116,26 @@ export default class LoginCommand extends BaseCommand<typeof LoginCommand> {
116116
}
117117

118118
const user: User = await authHandler.login(username, password, tfaToken);
119-
log.debug('Auth handler login completed', {
119+
log.debug('Auth handler login completed.', {
120120
...this.contextDetails,
121121
hasUser: !!user,
122122
hasAuthToken: !!user?.authtoken,
123123
userEmail: user?.email,
124124
});
125125

126126
if (typeof user !== 'object' || !user.authtoken || !user.email) {
127-
log.debug('Login failed - invalid user response', { ...this.contextDetails, user });
128-
throw new CLIError('Failed to login - invalid response');
127+
log.debug('Login failed: Invalid user response', { ...this.contextDetails, user });
128+
throw new CLIError('Login failed: Invalid response.');
129129
}
130130

131-
log.debug('Setting config data for basic auth', this.contextDetails);
131+
log.debug('Setting configuration data for basic authentication.', this.contextDetails);
132132
await oauthHandler.setConfigData('basicAuth', user);
133-
log.debug('Config data set successfully', this.contextDetails);
133+
log.debug('Configuration data set successfully.', this.contextDetails);
134134

135135
log.success(messageHandler.parse('CLI_AUTH_LOGIN_SUCCESS'), this.contextDetails);
136-
log.debug('Login process completed successfully', this.contextDetails);
136+
log.debug('Login completed successfully.', this.contextDetails);
137137
} catch (error) {
138-
log.debug('Login process failed', { ...this.contextDetails, error });
138+
log.debug('Login failed.', { ...this.contextDetails, error });
139139
throw error;
140140
}
141141
}

packages/contentstack-auth/src/commands/auth/logout.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {
6161
}
6262

6363
try {
64-
log.debug('Initializing management API client for logout', this.contextDetails);
64+
log.debug('Initializing the Management API client for logout.', this.contextDetails);
6565
const managementAPIClient = await managementSDKClient({ host: this.cmaHost, skipTokenValidity: true });
6666
log.debug('Management API client initialized successfully', this.contextDetails);
6767

@@ -75,9 +75,9 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {
7575
if (await oauthHandler.isAuthorisationTypeBasic()) {
7676
log.debug('Using basic authentication for logout', this.contextDetails);
7777
const authToken = configHandler.get('authtoken');
78-
log.debug('Retrieved auth token for logout', { ...this.contextDetails, hasAuthToken: !!authToken });
78+
log.debug('Authentication token retrieved for logout.', { ...this.contextDetails, hasAuthToken: !!authToken });
7979
await authHandler.logout(authToken);
80-
log.debug('Basic auth logout completed', this.contextDetails);
80+
log.debug('Basic authentication logout completed.', this.contextDetails);
8181
} else if (await oauthHandler.isAuthorisationTypeOAuth()) {
8282
log.debug('Using OAuth authentication for logout', this.contextDetails);
8383
await oauthHandler.oauthLogout();
@@ -86,7 +86,7 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {
8686

8787
cliux.loader('');
8888
log.success(messageHandler.parse('CLI_AUTH_LOGOUT_SUCCESS'), this.contextDetails);
89-
log.debug('Logout process completed successfully', this.contextDetails);
89+
log.debug('Logout completed successfully.', this.contextDetails);
9090
} else {
9191
log.debug('User not confirmed or not authenticated, skipping logout', {
9292
...this.contextDetails,
@@ -96,14 +96,14 @@ export default class LogoutCommand extends BaseCommand<typeof LogoutCommand> {
9696
log.success(messageHandler.parse('CLI_AUTH_LOGOUT_ALREADY'), this.contextDetails);
9797
}
9898
} catch (error) {
99-
log.debug('Logout command failed', { ...this.contextDetails, error: error.message });
99+
log.debug('Logout failed.', { ...this.contextDetails, error: error.message });
100100
cliux.print('CLI_AUTH_LOGOUT_FAILED', { color: 'yellow' });
101101
handleAndLogError(error, { ...this.contextDetails });
102102
} finally {
103103
if (confirm === true) {
104-
log.debug('Setting config data for logout', this.contextDetails);
104+
log.debug('Setting configuration data for logout.', this.contextDetails);
105105
await oauthHandler.setConfigData('logout');
106-
log.debug('Config data set for logout', this.contextDetails);
106+
log.debug('Configuration data set for logout.', this.contextDetails);
107107
}
108108
}
109109
}

packages/contentstack-auth/src/commands/auth/tokens/add.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
8282
'auth:tokens:add [-a <value>] [--delivery] [--management] [-e <value>] [-k <value>] [-y] [--token <value>]';
8383

8484
async run(): Promise<any> {
85-
log.debug('TokensAddCommand run method started', this.contextDetails);
85+
log.debug('TokensAddCommand run method started.', this.contextDetails);
8686
this.contextDetails.module = 'tokens-add';
8787

8888
const { flags: addTokenFlags } = await this.parse(TokensAddCommand);
89-
log.debug('Token add flags parsed', { ...this.contextDetails, flags: addTokenFlags });
89+
log.debug('Token add flags parsed.', { ...this.contextDetails, flags: addTokenFlags });
9090

9191
let isAliasExist = false;
9292
const skipAliasReplaceConfirmation = addTokenFlags.force || addTokenFlags.yes;
@@ -141,7 +141,7 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
141141

142142
if (!shouldAliasReplace) {
143143
log.debug('User declined alias replacement, exiting', this.contextDetails);
144-
log.info('Exiting from the process of replacing the token', this.contextDetails);
144+
log.info('Exiting the token replacement process.', this.contextDetails);
145145
cliux.print('CLI_AUTH_EXIT_PROCESS');
146146
return;
147147
}
@@ -150,13 +150,13 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
150150
if (!apiKey) {
151151
log.debug('No API key provided, requesting user input', this.contextDetails);
152152
apiKey = await cliux.inquire({ type: 'input', message: 'CLI_AUTH_TOKENS_ADD_ENTER_API_KEY', name: 'apiKey' });
153-
log.debug('API key obtained', { ...this.contextDetails, hasApiKey: !!apiKey });
153+
log.debug('API key obtained.', { ...this.contextDetails, hasApiKey: !!apiKey });
154154
}
155155

156156
if (!token) {
157157
log.debug('No token provided, requesting user input', this.contextDetails);
158158
token = await cliux.inquire({ type: 'input', message: 'CLI_AUTH_TOKENS_ADD_ENTER_TOKEN', name: 'token' });
159-
log.debug('Token obtained', { ...this.contextDetails, hasToken: !!token });
159+
log.debug('Token obtained.', { ...this.contextDetails, hasToken: !!token });
160160
}
161161

162162
if (isDelivery && !environment) {
@@ -183,12 +183,12 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
183183
// FIXME - Once the SDK refresh token issue is resolved, need to revert this back to SDK call
184184
const httpClient = new HttpClient({ headers: { api_key: apiKey, authorization: token } });
185185

186-
log.debug('Making management token validation API call', this.contextDetails);
186+
log.debug('Making management token validation API call.', this.contextDetails);
187187
const response = (await httpClient.get(`https://${this.cmaHost}/v3/environments?limit=1`)).data;
188-
log.debug('Management token validation response received', { ...this.contextDetails, response });
188+
log.debug('Management token validation response received.', { ...this.contextDetails, response });
189189

190190
if (response?.error_code === 105) {
191-
log.debug('Management token validation failed - invalid token', this.contextDetails);
191+
log.debug('Management token validation failed: invalid token.', this.contextDetails);
192192
throw new Error(messageHandler.parse('CLI_AUTH_TOKENS_VALIDATION_INVALID_MANAGEMENT_TOKEN'));
193193
} else if (response?.error_message) {
194194
log.debug('Management token validation failed with error message', {
@@ -197,7 +197,7 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
197197
});
198198
throw new Error(response.error_message);
199199
}
200-
log.debug('Management token validation successful', this.contextDetails);
200+
log.debug('Management token validation successful.', this.contextDetails);
201201
}
202202

203203
log.debug('Saving token to configuration', {
@@ -208,23 +208,23 @@ export default class TokensAddCommand extends BaseCommand<typeof TokensAddComman
208208
});
209209
if (isManagement) {
210210
configHandler.set(`${configKeyTokens}.${alias}`, { token, apiKey, type });
211-
log.debug('Management token saved to configuration', this.contextDetails);
211+
log.debug('Management token saved to configuration.', this.contextDetails);
212212
} else {
213213
configHandler.set(`${configKeyTokens}.${alias}`, { token, apiKey, environment, type });
214-
log.debug('Delivery token saved to configuration', this.contextDetails);
214+
log.debug('Delivery token saved to configuration.', this.contextDetails);
215215
}
216216

217217
if (isAliasExist) {
218-
log.debug('Token replaced successfully', this.contextDetails);
218+
log.debug('Token replaced successfully.', this.contextDetails);
219219
cliux.success('CLI_AUTH_TOKENS_ADD_REPLACE_SUCCESS');
220220
} else {
221-
log.debug('Token added successfully', this.contextDetails);
221+
log.debug('Token added successfully.', this.contextDetails);
222222
cliux.success('CLI_AUTH_TOKENS_ADD_SUCCESS');
223223
}
224224

225-
log.debug('Token add process completed successfully', this.contextDetails);
225+
log.debug('Token addition process completed successfully.', this.contextDetails);
226226
} catch (error) {
227-
log.debug('Token add process failed', { ...this.contextDetails, error });
227+
log.debug('Token addition process failed.', { ...this.contextDetails, error });
228228
cliux.print('CLI_AUTH_TOKENS_ADD_FAILED', { color: 'yellow' });
229229
handleAndLogError(error, { ...this.contextDetails });
230230
}

packages/contentstack-auth/src/commands/auth/tokens/index.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ export default class TokensListCommand extends BaseCommand<typeof TokensListComm
2323
]); // use the cli table flags as it displays tokens in table
2424

2525
async run(): Promise<any> {
26-
log.debug('TokensListCommand run method started', this.contextDetails);
26+
log.debug('TokensListCommand run method started.', this.contextDetails);
2727
this.contextDetails.module = 'tokens-list';
2828

2929
try {
30-
log.debug('Retrieving tokens from configuration', this.contextDetails);
30+
log.debug('Retrieving tokens from configuration.', this.contextDetails);
3131
const managementTokens = configHandler.get('tokens');
32-
log.debug('Tokens retrieved from configuration', {...this.contextDetails, tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 });
32+
log.debug('Tokens retrieved from configuration.', {...this.contextDetails, tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 });
3333

3434
const tokens: Record<string, unknown>[] = [];
3535
if (managementTokens && Object.keys(managementTokens).length > 0) {
36-
log.debug('Processing tokens for display', this.contextDetails);
36+
log.debug('Processing tokens for display.', this.contextDetails);
3737
Object.keys(managementTokens).forEach(function (item) {
3838
tokens.push({
3939
alias: item,
@@ -46,7 +46,7 @@ export default class TokensListCommand extends BaseCommand<typeof TokensListComm
4646
});
4747

4848
const { flags } = await this.parse(TokensListCommand);
49-
log.debug('Tokens list flags parsed', {...this.contextDetails, flags });
49+
log.debug('Token list flags parsed.', {...this.contextDetails, flags });
5050

5151
const headers = [
5252
{
@@ -66,17 +66,17 @@ export default class TokensListCommand extends BaseCommand<typeof TokensListComm
6666
},
6767
];
6868

69-
log.debug('Displaying tokens table', {...this.contextDetails, tokenCount: tokens.length });
69+
log.debug('Displaying token table.', {...this.contextDetails, tokenCount: tokens.length });
7070
cliux.table(headers, tokens, flags as TableFlags);
71-
log.debug('Tokens table displayed successfully', this.contextDetails);
71+
log.debug('Token table displayed successfully.', this.contextDetails);
7272
} else {
73-
log.debug('No tokens found in configuration', this.contextDetails);
73+
log.debug('No tokens found in configuration.', this.contextDetails);
7474
cliux.print('CLI_AUTH_TOKENS_LIST_NO_TOKENS');
7575
}
7676

77-
log.debug('Tokens list command completed successfully', this.contextDetails);
77+
log.debug('Token list command completed successfully.', this.contextDetails);
7878
} catch (error) {
79-
log.debug('Tokens list command failed', {...this.contextDetails, error });
79+
log.debug('Token list command failed.', {...this.contextDetails, error });
8080
cliux.print('CLI_AUTH_TOKENS_LIST_FAILED', { color: 'yellow' });
8181
handleAndLogError(error, { ...this.contextDetails });
8282
}

0 commit comments

Comments
 (0)