{"record":{"id":"ff35dc74ea53140c","repo":"OtterMind/Chat2DB","slug":"the-baseurl-is-not-valid","errorCode":null,"errorMessage":"The baseURL is not valid!","messagePattern":"The baseURL is not valid!","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"chat2db-community-client/src/components/SSERequest/sseClientRequest.ts","lineNumber":26,"sourceCode":"export type SSEFields = 'data' | 'event' | 'id' | 'retry';\nexport type SSEOutput = Partial<Record<SSEFields, any>>;\n\nclass ClientRequestClass {\n  readonly baseURL;\n  readonly model;\n\n  private constructor(options: SSERequestOptions) {\n    const { baseURL, model } = options;\n\n    this.baseURL = baseURL;\n    this.model = model;\n  }\n\n  private static instanceBuffer: Map<string | typeof fetch, ClientRequestClass> = new Map();\n\n  public static init(options: SSERequestOptions): ClientRequestClass {\n    if (!options.baseURL || typeof options.baseURL !== 'string') {\n      throw new Error('The baseURL is not valid!');\n    }\n\n    const id = options.baseURL;\n\n    if (!ClientRequestClass.instanceBuffer.has(id)) {\n      ClientRequestClass.instanceBuffer.set(id, new ClientRequestClass(options));\n    }\n\n    return ClientRequestClass.instanceBuffer.get(id)!;\n  }\n\n  public create<Input = AnyObject, Output = SSEOutput>(\n    params: SSERequestParams & Input,\n    callbacks: SSERequestCallbacks<Output>,\n    _transformStream?: SSEStreamProps<Output>['transformStream'],\n  ): SSERequestHandle {\n    const currentRequest: IJcefSseRequest = sendClientSSERequest(this.baseURL, params);\n    const eventName = `${JavaPushActionType.AI_SSE_MESSAGE}_${currentRequest.requestId}`;","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-client/src/components/SSERequest/sseClientRequest.ts#L8-L44","documentation":"ClientRequestClass.init throws when options.baseURL is falsy or not a string. The SSE client request manager needs a valid endpoint URL to route AI streaming events through the JCEF bridge (sendClientSSERequest), so it rejects initialization early. The class uses a singleton buffer keyed by baseURL, so an invalid key would corrupt the cache.","triggerScenarios":"Calling ClientRequestClass.init({ baseURL: undefined | null | '' | 123, model }) — typically when the AI/SSE configuration is missing or loaded asynchronously and the init runs before the config is populated.","commonSituations":"AI assistant settings not yet loaded from the backend when the SSE client initializes. A user has not configured an AI provider, leaving baseURL empty. Race condition where the component mounts before config fetch resolves.","solutions":["Ensure baseURL is a populated string before calling init; defer init until config is loaded.","Add a default/fallback AI endpoint in configuration when none is configured.","Guard: if (!config?.baseURL) return null; before init, and skip mounting the AI streaming component."],"exampleFix":"// before\nconst client = ClientRequestClass.init({ baseURL: config.baseURL, model });\n\n// after\nif (!config?.baseURL || typeof config.baseURL !== 'string') {\n  return null;\n}\nconst client = ClientRequestClass.init({ baseURL: config.baseURL, model });","handlingStrategy":"validation","validationCode":"function isValidBaseURL(v: unknown): v is string {\n  return typeof v === 'string' && v.length > 0;\n}\n\nif (isValidBaseURL(options.baseURL)) {\n  ClientRequestClass.init(options);\n}","typeGuard":"function isValidBaseURL(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0 && /^https?:\\/\\/.+/.test(v);\n}","tryCatchPattern":null,"preventionTips":["Load AI configuration before mounting the SSE client component.","Default baseURL from a config service with a non-empty fallback.","Type the options strictly so baseURL is required string at compile time."],"tags":["sse","ai","config","validation","frontend"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}