[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
This commit is contained in:
Miguel Serrano
2026-06-10 11:57:51 +00:00
committed by Copybot
parent c9e4ab8b99
commit 4ab8de3e38
3 changed files with 28 additions and 2 deletions
@@ -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' ||
@@ -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
@@ -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(