From 4ab8de3e38a51dfd5c78d5499ecd71a4d0c9c676 Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Wed, 10 Jun 2026 10:35:30 +0200 Subject: [PATCH] [web] Skip GeoIpLookup on CE/SP (#34348) The regression was introduced in 487e1767b8ac531588a272f0492a900c24162b33. GeoIp is not configured in CE/SP, yielding an error log when rendering the project list. GitOrigin-RevId: 55410611a5fef95daa5914a31969893107777593 --- .../src/Features/Project/ProjectListController.mjs | 9 +++++++-- .../web/app/src/infrastructure/GeoIpLookup.mjs | 7 +++++++ .../src/Project/ProjectListController.test.mjs | 14 ++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectListController.mjs b/services/web/app/src/Features/Project/ProjectListController.mjs index a56251e918..fd433541c3 100644 --- a/services/web/app/src/Features/Project/ProjectListController.mjs +++ b/services/web/app/src/Features/Project/ProjectListController.mjs @@ -501,8 +501,13 @@ async function projectListPage(req, res, next) { let showInrGeoBanner = false let showLATAMBanner = false let recommendedCurrency - const { countryCode, currencyCode } = - await GeoIpLookup.promises.getCurrencyCode(req.ip) + let countryCode + let currencyCode + if (isSaas) { + const currencyData = await GeoIpLookup.promises.getCurrencyCode(req.ip) + countryCode = currencyData.countryCode + currencyCode = currencyData.currencyCode + } if ( usersBestSubscription?.type === 'free' || diff --git a/services/web/app/src/infrastructure/GeoIpLookup.mjs b/services/web/app/src/infrastructure/GeoIpLookup.mjs index ba9d05cba7..110c0d2a00 100644 --- a/services/web/app/src/infrastructure/GeoIpLookup.mjs +++ b/services/web/app/src/infrastructure/GeoIpLookup.mjs @@ -91,6 +91,13 @@ async function getDetails(ip, callback) { if (!ip) { return callback(new Error('no ip passed')) } + if (!settings.apis.geoIpLookup?.url) { + logger.warn( + {}, + 'settings.apis.geoIpLookup.url is not configured, skipping lookup' + ) + return + } ip = ip.trim().split(' ')[0] const url = new URL(settings.apis.geoIpLookup.url) url.pathname += ip diff --git a/services/web/test/unit/src/Project/ProjectListController.test.mjs b/services/web/test/unit/src/Project/ProjectListController.test.mjs index c9b874c414..d7c9746b84 100644 --- a/services/web/test/unit/src/Project/ProjectListController.test.mjs +++ b/services/web/test/unit/src/Project/ProjectListController.test.mjs @@ -467,6 +467,20 @@ describe('ProjectListController', function () { await ctx.ProjectListController.projectListPage(ctx.req, ctx.res) }) + it('should look up geo IP in saas', async function (ctx) { + ctx.Features.hasFeature.withArgs('saas').returns(true) + ctx.res.render = () => {} + await ctx.ProjectListController.projectListPage(ctx.req, ctx.res) + expect(ctx.GeoIpLookup.promises.getCurrencyCode).to.have.been.calledOnce + }) + + it('should not look up geo IP in a non-saas environment', async function (ctx) { + ctx.Features.hasFeature.withArgs('saas').returns(false) + ctx.res.render = () => {} + await ctx.ProjectListController.projectListPage(ctx.req, ctx.res) + expect(ctx.GeoIpLookup.promises.getCurrencyCode).to.not.have.been.called + }) + it('should send groupRole to customer.io for group admins', async function (ctx) { ctx.Features.hasFeature.withArgs('saas').returns(true) ctx.SubscriptionViewModelBuilder.promises.getUsersSubscriptionDetails.resolves(