{"record":{"id":"7eba3ff077a9446e","repo":"OtterMind/Chat2DB","slug":"license-flow-is-disabled-in-community-mode-7eba3f","errorCode":null,"errorMessage":"License flow is disabled in community mode","messagePattern":"License flow is disabled in community mode","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"chat2db-community-client/src/service/license.ts","lineNumber":10,"sourceCode":"import { IUserVO } from '@/typings/enterprise/user';\nimport createRequest from './base';\nimport { ILicenseDeviceCerVO, ILicenseVO } from '@/typings/license';\n\nconst licenseService =\n  __RUNTIME_ENV__ === 'community'\n    ? {\n        startTrial: async () => undefined,\n        validLicense: async () => {\n          throw new Error('License flow is disabled in community mode');\n        },\n        removeLicense: async () => undefined,\n        sendEmailLicense: async () => undefined,\n        checkPasscode: async () => undefined,\n        getDeviceId: async () => '',\n        activateCer: async () => undefined,\n        getLicenseList: async () => [] as ILicenseVO[],\n        generateCertificate: async () => '',\n        listCertificate: async () => [] as ILicenseDeviceCerVO[],\n        deactivateOnline: async () => undefined,\n      }\n    : (() => {\n        const prefix = '/api/license';\n\n        const startTrial = createRequest<void, IUserVO>(`${prefix}/start_trial_a`, {\n          method: 'post',\n        });\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-client/src/service/license.ts#L1-L28","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Guard the call site: only call validLicense when __RUNTIME_ENV__ !== 'community'.","Wrap in try/catch and treat the throw as 'unlicensed' to fall back gracefully.","Remove the license-probe code path for Community builds via tree-shaken conditional imports."],"exampleFix":"// before\nconst valid = await licenseService.validLicense();\n\n// after\nlet valid = false;\nif (__RUNTIME_ENV__ !== 'community') {\n  valid = await licenseService.validLicense();\n}","handlingStrategy":"validation","validationCode":"if (__RUNTIME_ENV__ === 'community') {\n  // skip license validation; Community has no license concept\n  return false;\n}\nreturn await licenseService.validLicense();","typeGuard":"function isLicenseSupported(): boolean {\n  return typeof __RUNTIME_ENV__ === 'string' && __RUNTIME_ENV__ !== 'community';\n}","tryCatchPattern":"let valid = false;\ntry {\n  valid = await licenseService.validLicense();\n} catch (e) {\n  if (!(e instanceof Error && /disabled in community mode/.test(e.message))) throw e;\n}","preventionTips":["Centralize edition checks in a useEdition() hook or context.","Gate license-gated features behind edition, not behind the license call result.","Review license call sites during Community build smoke tests."],"tags":["community-mode","license","feature-flag","runtime-env","frontend"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}