Skip to content

tenantService.js shadows tenantService.ts — historicalDataService throws getTenantScopedDbName is not a function on import, and check:shadowing fails CI for every PR #1049

Description

@MOHITKOURAV01

src/services/tenantService.js shadows src/services/tenantService.ts, so historicalDataService throws on import and the shadowing gate is red on main.

What happened

The multi-tenant workspace work (#1031, merged as #1036) added a new src/services/tenantService.js. A src/services/tenantService.ts was already there, added by the tenant-scoping work for #759. Both files answer to the same extensionless specifier:

src/services/tenantService
  - src/services/tenantService.js   (API client: fetchUserTenants, updateTenantSettings, ...)
  - src/services/tenantService.ts   (scoping helpers: getTenantScopedDbName, getTenantScopedStoreName, ...)

This is exactly the failure #990 was opened for, and the guard added with it already catches it. On current main:

$ npm run check:shadowing
Shadowed modules found. Each of these resolves differently under Vite and tsc:

  src/services/tenantService
    - src/services/tenantService.js
    - src/services/tenantService.ts

check:shadowing is a blocking step in the lint job of .github/workflows/ci.yml, so every PR opened against main right now fails CI on a problem its author did not cause. src/tests/moduleShadowing.test.js is red for the same reason.

Why it is not just a lint failure

src/services/historicalDataService.js opens with:

import { getTenantScopedDbName, getTenantScopedStoreName } from './tenantService';

const SCOPED_DB_NAME = getTenantScopedDbName(DB_NAME);
const SCOPED_STORE_NAME = getTenantScopedStoreName(STORE_NAME);

Vite's default resolve.extensions puts .js ahead of .ts, so the specifier now lands on the API-client file — which exports none of those helpers. Both bindings are undefined, and the two calls run at module evaluation time, so the import itself throws:

TypeError: getTenantScopedDbName is not a function

That is not a degraded cache; the module cannot be loaded at all, and it takes every importer down with it. Seven test files fail on that single line today:

src/App.theme.test.jsx
src/components/AnalyticsInsights.test.jsx
src/components/HistoricalData.test.jsx
src/components/SectionNav.test.jsx
src/services/historicalDataService.cache.test.js
src/services/historicalDataService.test.js
src/tests/moduleShadowing.test.js

In the browser that is the Historical Analysis panel, the calendar heatmap, the AI insights card and the CSV/heatmap export — anything that reaches fetchHistoricalData.

Reproduce

npm ci
npm run check:shadowing          # exits 1
npx vitest run src/services/historicalDataService.test.js

Expected

One file answers to ./tenantService. The two modules are unrelated in purpose but not in name — the scoping helpers and the workspace API client should live in a single module (or one of them should be renamed), so that getTenantScopedDbName resolves for historicalDataService and fetchUserTenants resolves for TenantContext. npm run check:shadowing should exit 0 and the seven test files above should pass.

A regression test asserting that historicalDataService can be imported at all would be worth having — the current tests all fail at import, which is not obviously distinguishable from "the suite is broken".

Metadata

Metadata

Labels

ECSoC26Contributions considered under ECSoC'26

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions