OtterMind/Chat2DB · error · Error

The baseURL is not valid!

Error message

The baseURL is not valid!

What it means

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.

Source

Thrown at chat2db-community-client/src/components/SSERequest/sseClientRequest.ts:26

export type SSEFields = 'data' | 'event' | 'id' | 'retry';
export type SSEOutput = Partial<Record<SSEFields, any>>;

class ClientRequestClass {
  readonly baseURL;
  readonly model;

  private constructor(options: SSERequestOptions) {
    const { baseURL, model } = options;

    this.baseURL = baseURL;
    this.model = model;
  }

  private static instanceBuffer: Map<string | typeof fetch, ClientRequestClass> = new Map();

  public static init(options: SSERequestOptions): ClientRequestClass {
    if (!options.baseURL || typeof options.baseURL !== 'string') {
      throw new Error('The baseURL is not valid!');
    }

    const id = options.baseURL;

    if (!ClientRequestClass.instanceBuffer.has(id)) {
      ClientRequestClass.instanceBuffer.set(id, new ClientRequestClass(options));
    }

    return ClientRequestClass.instanceBuffer.get(id)!;
  }

  public create<Input = AnyObject, Output = SSEOutput>(
    params: SSERequestParams & Input,
    callbacks: SSERequestCallbacks<Output>,
    _transformStream?: SSEStreamProps<Output>['transformStream'],
  ): SSERequestHandle {
    const currentRequest: IJcefSseRequest = sendClientSSERequest(this.baseURL, params);
    const eventName = `${JavaPushActionType.AI_SSE_MESSAGE}_${currentRequest.requestId}`;

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Ensure baseURL is a populated string before calling init; defer init until config is loaded.
  2. Add a default/fallback AI endpoint in configuration when none is configured.
  3. Guard: if (!config?.baseURL) return null; before init, and skip mounting the AI streaming component.

Example fix

// before
const client = ClientRequestClass.init({ baseURL: config.baseURL, model });

// after
if (!config?.baseURL || typeof config.baseURL !== 'string') {
  return null;
}
const client = ClientRequestClass.init({ baseURL: config.baseURL, model });
Defensive patterns

Strategy: validation

Validate before calling

function isValidBaseURL(v: unknown): v is string {
  return typeof v === 'string' && v.length > 0;
}

if (isValidBaseURL(options.baseURL)) {
  ClientRequestClass.init(options);
}

Type guard

function isValidBaseURL(v: unknown): v is string {
  return typeof v === 'string' && v.trim().length > 0 && /^https?:\/\/.+/.test(v);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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