mastra-ai/mastra · error · Error

HTTP URL is required

Error message

HTTP URL is required

What it means

The HttpLogger transport requires a target URL; the constructor throws 'HTTP URL is required' when options.url is missing, null, or an empty string. Without a URL there is nowhere to POST log entries.

Source

Thrown at packages/loggers/src/http/index.ts:36

}

export class HttpTransport extends LoggerTransport {
  private url: string;
  private method: string;
  private headers: Record<string, string>;
  private batchSize: number;
  private flushInterval: number;
  private timeout: number;
  private retryOptions: Required<RetryOptions>;
  private logBuffer: BaseLogMessage[];
  private lastFlush: number;
  private flushIntervalId: NodeJS.Timeout;

  constructor(options: HttpTransportOptions) {
    super({ objectMode: true });

    if (!options.url) {
      throw new Error('HTTP URL is required');
    }

    this.url = options.url;
    this.method = options.method || 'POST';
    this.headers = {
      'Content-Type': 'application/json',
      ...options.headers,
    };
    this.batchSize = options.batchSize || 100;
    this.flushInterval = options.flushInterval || 10000;
    this.timeout = options.timeout || 30000;
    this.retryOptions = {
      maxRetries: options.retryOptions?.maxRetries || 3,
      retryDelay: options.retryOptions?.retryDelay || 1000,
      exponentialBackoff: options.retryOptions?.exponentialBackoff || true,
    };

    this.logBuffer = [];

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Pass a valid url option, e.g. { url: 'https://logs.example.com/collect' }.
  2. Check the environment variable feeding options.url is set and non-empty (fail fast at startup with a clear message).
  3. Fix the option key spelling — it must be exactly url.

Example fix

// before
const logger = new HttpTransport({ url: process.env.LOG_URL }); // throws if unset
// after
if (!process.env.LOG_URL) throw new Error('LOG_URL env var must be set');
const logger = new HttpTransport({ url: process.env.LOG_URL, method: 'POST' });
Defensive patterns

Strategy: validation

Validate before calling

function assertHttpTransportOptions(opts) {
  if (!opts.url || !/^https?:\/\//.test(opts.url)) {
    throw new Error('HttpTransport requires a valid http(s) url');
  }
}

Type guard

function hasUrl(opts) {
  return typeof opts.url === 'string' && opts.url.length > 0;
}

Try / catch

try {
  const logger = new HttpTransport({ url: process.env.LOG_URL });
} catch (e) {
  if (e.message === 'HTTP URL is required') {
    console.error('LOG_URL is not configured');
  }
  throw e;
}

Prevention

When it happens

Trigger: new HttpTransport({}) or HttpTransport({ url: process.env.LOG_URL }) where the env var is unset (undefined) or empty.

Common situations: Missing LOG_ENDPOINT-style environment variable; options object constructed conditionally and url branch skipped; typo in option key (uri/endpoint instead of url).

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/fb705244ce0715b4. Report an issue: GitHub.