OtterMind/Chat2DB · warning · Error

License flow is disabled in community mode

Error message

License flow is disabled in community mode

What it means

This is the runtime-environment-conditional version of the license stub (service/license.ts), functionally identical to the community-stubs version. When __RUNTIME_ENV__ === 'community', the same validLicense method throws 'License flow is disabled in community mode'. At build time, UMI_ENV=community sets this constant, selecting the throwing branch. The non-community branch wires to the real createRequest-based license API.

Source

Thrown at chat2db-community-client/src/service/license.ts:10

import { IUserVO } from '@/typings/enterprise/user';
import createRequest from './base';
import { ILicenseDeviceCerVO, ILicenseVO } from '@/typings/license';

const licenseService =
  __RUNTIME_ENV__ === 'community'
    ? {
        startTrial: async () => undefined,
        validLicense: async () => {
          throw new Error('License flow is disabled in community mode');
        },
        removeLicense: async () => undefined,
        sendEmailLicense: async () => undefined,
        checkPasscode: async () => undefined,
        getDeviceId: async () => '',
        activateCer: async () => undefined,
        getLicenseList: async () => [] as ILicenseVO[],
        generateCertificate: async () => '',
        listCertificate: async () => [] as ILicenseDeviceCerVO[],
        deactivateOnline: async () => undefined,
      }
    : (() => {
        const prefix = '/api/license';

        const startTrial = createRequest<void, IUserVO>(`${prefix}/start_trial_a`, {
          method: 'post',
        });

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Guard the call site: only call validLicense when __RUNTIME_ENV__ !== 'community'.
  2. Wrap in try/catch and treat the throw as 'unlicensed' to fall back gracefully.
  3. Remove the license-probe code path for Community builds via tree-shaken conditional imports.

Example fix

// before
const valid = await licenseService.validLicense();

// after
let valid = false;
if (__RUNTIME_ENV__ !== 'community') {
  valid = await licenseService.validLicense();
}
Defensive patterns

Strategy: validation

Validate before calling

if (__RUNTIME_ENV__ === 'community') {
  // skip license validation; Community has no license concept
  return false;
}
return await licenseService.validLicense();

Type guard

function isLicenseSupported(): boolean {
  return typeof __RUNTIME_ENV__ === 'string' && __RUNTIME_ENV__ !== 'community';
}

Try / catch

let valid = false;
try {
  valid = await licenseService.validLicense();
} catch (e) {
  if (!(e instanceof Error && /disabled in community mode/.test(e.message))) throw e;
}

Prevention

When it happens

Trigger: Calling licenseService.validLicense() when the build was compiled with UMI_ENV=community. This happens when a component doesn't check the edition before calling validLicense, or a shared code path invokes it unconditionally.

Common situations: A component shared between Community and Enterprise renders in a Community build and calls validLicense without an edition gate. An AI/feature gate that probes license status but isn't disabled for Community. Upgrading the frontend without re-checking edition guards after a refactor.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/7eba3ff077a9446e. Report an issue: GitHub.