HeyPuter/puter · error · HttpError

bad_request

bad_request

Error message

`file` is required

What it means

The base provider's requireFile(args) rejects when args.file is falsy. The OpenAI provider calls this.requireFile(args) before loadFileInput, so a missing file never reaches file resolution (which has its own 'Missing file input' 400). file is the STT equivalent of audio — a path, data URL, web URL, or {path/uid/uuid}.

Source

Thrown at src/backend/drivers/ai-speech2txt/providers/SpeechToTextProvider.ts:67

    getReportedCosts(): Record<string, unknown>[] {
        return [];
    }

    /** The authenticated caller, or a 401 if the request carries none. */
    protected requireActor(): Actor {
        const actor = Context.get('actor') as Actor | undefined;
        if (!actor)
            throw new HttpError(401, 'Authentication required', {
                legacyCode: 'unauthorized',
            });
        return actor;
    }

    /** Reject the call unless the caller supplied audio. */
    protected requireFile(args: ITranscribeArgs): void {
        if (!args.file)
            throw new HttpError(400, '`file` is required', {
                legacyCode: 'bad_request',
            });
    }
}

View on GitHub (pinned to 908ec23eda)

Solutions

  1. Provide file as a data URL, an FS path string, { path }, { uid } / { uuid }, or an accepted web URL.
  2. Validate a non-empty file reference client-side before the request.

Example fix

// before
driver.transcribe({ model: 'whisper-1' })
// after
driver.transcribe({ file: '/alice/sample.mp3', model: 'whisper-1' })
Defensive patterns

Strategy: validation

Validate before calling

if (!args.file) throw new Error('`file` is required');

Type guard

function hasFile(a): a is { file: string | Record<string, unknown> } {
  return Boolean(a && (typeof a.file === 'string' || (a.file && typeof a.file === 'object')));
}

Prevention

When it happens

Trigger: Calling transcribe({ model }) with no file; file: null / undefined / ''; a field renamed from audio to file mid-migration leaving the field empty.

Common situations: UI submit before an audio file is attached; field rename from audio to file leaving the field empty; an empty upload payload.

Related errors


AI-assisted analysis of HeyPuter/puter@908ec23eda (2026-08-12). Data as JSON: /api/errors/f2fb4cc232832045. Report an issue: GitHub.