{"record":{"id":"64b03162bc177698","repo":"hcengineering/platform","slug":"payment-service-url-not-specified","errorCode":null,"errorMessage":"Payment service URL not specified","messagePattern":"Payment service URL not specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/payment-client/src/client.ts","lineNumber":28,"sourceCode":"// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n//\n// See the License for the specific language governing permissions and\n// limitations under the License.\n//\n\nimport { concatLink, type WorkspaceUuid } from '@hcengineering/core'\nimport { CheckoutResponse, SubscribeRequest, CheckoutStatus, SubscriptionData } from './types'\nimport { PaymentError, NetworkError } from './error'\n\n/**\n * Create a payment client instance\n * @param paymentUrl - URL of the payment service\n * @param token - Authentication token\n * @returns PaymentClient instance\n */\nexport function getClient (paymentUrl?: string, token?: string): PaymentClient {\n  if (paymentUrl === undefined || paymentUrl == null || paymentUrl === '') {\n    throw new Error('Payment service URL not specified')\n  }\n  if (token === undefined || token == null || token === '') {\n    throw new Error('Authentication token not specified')\n  }\n\n  return new PaymentClient(paymentUrl, token)\n}\n\n/**\n * Payment service client\n * Handles all subscription and payment operations\n */\nexport class PaymentClient {\n  private readonly headers: Record<string, string>\n\n  constructor (\n    private readonly endpoint: string,\n    private readonly token: string","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/packages/payment-client/src/client.ts#L10-L46","documentation":"The payment-client package exposes a `getClient` factory that validates its arguments and throws this Error when paymentUrl is undefined, null, or an empty string. The factory refuses to build a PaymentClient without a service endpoint since every subsequent call would fail. It fails fast so misconfiguration is caught at client-creation time.","triggerScenarios":"Calling `getClient()` with no arguments, or `getClient(undefined, token)` / `getClient('', token)` — typically when the payment service URL config or env var is missing.","commonSituations":"PAYMENT_URL environment variable not set in a deployment, forgotten config entry, or code refactored to pass the URL dynamically where the value became empty.","solutions":["Pass the actual payment service URL as the first argument, e.g. `getClient('https://payments.example.com', token)`.","Ensure the environment variable feeding paymentUrl (e.g. PAYMENT_URL) is set in the runtime environment.","Check the call site for a wrong-order argument mistake (URL vs token swapped)."],"exampleFix":"// before\nconst client = getClient(process.env.PAYMENT_URL, token)\n// after\nif (!process.env.PAYMENT_URL) throw new Error('PAYMENT_URL env var required')\nconst client = getClient(process.env.PAYMENT_URL, token)","handlingStrategy":"validation","validationCode":"function assertPaymentUrl(url: string | undefined | null): asserts url is string {\n  if (url == null || url === '') throw new Error('PAYMENT_URL must be set before creating payment client')\n}\nassertPaymentUrl(process.env.PAYMENT_URL)\nconst client = getClient(process.env.PAYMENT_URL as string, token)","typeGuard":"function hasPaymentUrl(url: unknown): url is string {\n  return typeof url === 'string' && url.trim() !== ''\n}","tryCatchPattern":"try {\n  const client = getClient(url, token)\n} catch (e) {\n  if ((e as Error).message === 'Payment service URL not specified') {\n    throw new Error('Config error: PAYMENT_URL missing')\n  }\n  throw e\n}","preventionTips":["Load and validate payment config at startup with a schema validator.","Keep URL and token argument order consistent; prefer an options object at the call site.","Fail fast in CI/startup checks when required env vars are absent."],"tags":["configuration","factory","payment","client"],"backgroundTag":"missing-service-url","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}