From 96767f915f2e882c747ab6f69126cfe84a700b24 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Tue, 25 Aug 2026 10:38:35 +0200 Subject: [PATCH] Improve validation of activities and asset profiles when combining custom asset profile symbol with data source other than MANUAL --- apps/api/src/app/import/import.service.ts | 15 ++++++++++++--- .../data-provider/data-provider.service.ts | 10 ++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/api/src/app/import/import.service.ts b/apps/api/src/app/import/import.service.ts index 47935c9a7..45fd0f714 100644 --- a/apps/api/src/app/import/import.service.ts +++ b/apps/api/src/app/import/import.service.ts @@ -212,12 +212,21 @@ export class ImportService { for (const [index, assetProfileWithMarketData] of ( assetProfilesWithMarketDataDto ?? [] ).entries()) { + const { dataSource, symbol } = assetProfileWithMarketData; + if ( - assetProfileWithMarketData.dataSource === DataSource.MANUAL && - !isValidCustomAssetProfileSymbol(assetProfileWithMarketData.symbol) + dataSource === DataSource.MANUAL && + !isValidCustomAssetProfileSymbol(symbol) + ) { + throw new Error( + `assetProfiles.${index}.symbol ("${symbol}") must be a UUID or start with the prefix "${ghostfolioPrefix}_" for the data source ("${DataSource.MANUAL}")` + ); + } else if ( + dataSource !== DataSource.MANUAL && + isValidCustomAssetProfileSymbol(symbol) ) { throw new Error( - `assetProfiles.${index}.symbol ("${assetProfileWithMarketData.symbol}") must be a UUID or start with the prefix "${ghostfolioPrefix}_" for the data source ("${DataSource.MANUAL}")` + `assetProfiles.${index}.symbol ("${symbol}") is not valid for the data source ("${dataSource}")` ); } } diff --git a/apps/api/src/services/data-provider/data-provider.service.ts b/apps/api/src/services/data-provider/data-provider.service.ts index e9449be9e..d8a3d79ef 100644 --- a/apps/api/src/services/data-provider/data-provider.service.ts +++ b/apps/api/src/services/data-provider/data-provider.service.ts @@ -23,6 +23,7 @@ import { getStartOfUtcDate, isCurrency, isDerivedCurrency, + isValidCustomAssetProfileSymbol, isValidSearchQuery } from '@ghostfolio/common/helper'; import { @@ -254,6 +255,15 @@ export class DataProviderService implements OnModuleInit { ); } + if ( + dataSource !== DataSource.MANUAL && + isValidCustomAssetProfileSymbol(symbol) + ) { + throw new Error( + `${activityPath}.symbol ("${symbol}") is not valid for the specified data source ("${maskedDataSource}")` + ); + } + if ( this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION') && subscription?.type === SubscriptionType.Basic