more logging

This commit is contained in:
dal 2025-07-07 17:31:47 -06:00
parent 3843ec3931
commit 19fe3748d2
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
3 changed files with 24 additions and 1 deletions

View File

@ -85,6 +85,9 @@ export class SlackAuthService {
// Exchange code for tokens
const tokenResponse = await this.exchangeCodeForTokens(code);
// Log the raw response for debugging
console.info('Slack OAuth raw response:', JSON.stringify(tokenResponse, null, 2));
// Validate response
const oauthData = validateWithSchema(
SlackOAuthResponseSchema,
@ -213,6 +216,18 @@ export class SlackAuthService {
}
const data = await response.json();
// Check if Slack returned an error in the response body
const responseData = data as { ok?: boolean; error?: string; error_description?: string };
if (responseData.ok === false || responseData.error) {
console.error('Slack OAuth error response:', {
ok: responseData.ok,
error: responseData.error,
error_description: responseData.error_description,
fullResponse: data,
});
}
return data;
} catch (error) {
if (error instanceof SlackIntegrationError) {

View File

@ -17,6 +17,14 @@ export function validateWithSchema<T>(
const result = schema.safeParse(data);
if (!result.success) {
// Log detailed validation errors for debugging
console.error('Schema validation failed:', {
message: errorMessage,
errors: result.error.errors,
flattened: result.error.flatten(),
receivedData: data,
});
throw new SlackIntegrationError('UNKNOWN_ERROR', errorMessage, false, {
zodError: result.error.flatten(),
});