From 82894993c1e3a2b9eccd7998e6412112bd2a5d15 Mon Sep 17 00:00:00 2001 From: Maryermarh Date: Mon, 29 Jun 2026 15:54:57 +0100 Subject: [PATCH] fix: resolve template literal and buildDataKey issues BE-01 Fix buildDataKey returning bare doc_ prefix (#726) BE-15 Fix ternary operator bug in GitHub strategy (#727) BE-15 Fix broken template literal in HttpExceptionFilter (#728) BE-15 Fix template literal syntax issue in OAuth callback URLs (#729) --- backend/src/auth/strategies/github.strategy.ts | 9 ++++++--- backend/src/auth/strategies/google.strategy.ts | 9 ++++++--- backend/src/common/filters/http-exception.filter.ts | 2 +- backend/src/stellar/stellar.service.ts | 5 +++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/backend/src/auth/strategies/github.strategy.ts b/backend/src/auth/strategies/github.strategy.ts index 3ee665b0..24ad9c57 100644 --- a/backend/src/auth/strategies/github.strategy.ts +++ b/backend/src/auth/strategies/github.strategy.ts @@ -13,12 +13,15 @@ export class GithubStrategy extends PassportStrategy(Strategy, 'github') { throw new Error('GitHub OAuth client credentials are not configured'); } + const appUrl = (configService.get('APP_URL') || 'http://localhost:6004').replace(/\/+$/, ''); + const callbackURL = + configService.get('GITHUB_CALLBACK_URL') ?? + `${appUrl}/api/auth/github/callback`; + super({ clientID, clientSecret, - callbackURL: - configService.get('GITHUB_CALLBACK_URL') || - `${configService.get('APP_URL') || 'http://localhost:6004'}/api/auth/github/callback`, + callbackURL, scope: ['user:email'], }); } diff --git a/backend/src/auth/strategies/google.strategy.ts b/backend/src/auth/strategies/google.strategy.ts index 49bf060f..39d4a998 100644 --- a/backend/src/auth/strategies/google.strategy.ts +++ b/backend/src/auth/strategies/google.strategy.ts @@ -13,12 +13,15 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { throw new Error('Google OAuth client credentials are not configured'); } + const appUrl = (configService.get('APP_URL') || 'http://localhost:6004').replace(/\/+$/, ''); + const callbackURL = + configService.get('GOOGLE_CALLBACK_URL') ?? + `${appUrl}/api/auth/google/callback`; + super({ clientID, clientSecret, - callbackURL: - configService.get('GOOGLE_CALLBACK_URL') || - `${configService.get('APP_URL') || 'http://localhost:6004'}/api/auth/google/callback`, + callbackURL, scope: ['email', 'profile'], }); } diff --git a/backend/src/common/filters/http-exception.filter.ts b/backend/src/common/filters/http-exception.filter.ts index 84ea3dcc..ffaa3d00 100644 --- a/backend/src/common/filters/http-exception.filter.ts +++ b/backend/src/common/filters/http-exception.filter.ts @@ -38,7 +38,7 @@ export class HttpExceptionFilter implements ExceptionFilter { path: request.url, }; - this.logger.error(`${status} -> `, (exception as Error)?.stack); + this.logger.error(`HTTP ${status} Error -> ${request.method} ${request.url}`, (exception as Error)?.stack); if (!this.isProduction && exception instanceof Error) { Object.assign(payload, { stack: exception.stack }); diff --git a/backend/src/stellar/stellar.service.ts b/backend/src/stellar/stellar.service.ts index bc64d57a..1b3cb8c2 100644 --- a/backend/src/stellar/stellar.service.ts +++ b/backend/src/stellar/stellar.service.ts @@ -1,4 +1,5 @@ import { + Inject, Injectable, BadRequestException, InternalServerErrorException, @@ -12,6 +13,7 @@ import { Operation, TransactionBuilder, } from 'stellar-sdk'; +import { CacheService } from '../cache/cache.service'; @Injectable() export class StellarService { @@ -55,6 +57,9 @@ export class StellarService { private buildDataKey(hash: string) { this.validateHash(hash); const payload = hash.slice(0, 58); + if (!payload) { + throw new BadRequestException('Hash produced empty data key payload'); + } return `doc_${payload}`; }