Skip to content

AI Assistant: HTTP 302 from custom OpenAI-compatible endpoint is reported as failure instead of following redirect #41932

Description

@x3x3n0m0rph

Description

When using a custom inference provider (OpenAI-compatible Base URL), the AI Assistant fails with:

OpenAI request failed: HTTP 302

Browsers and many HTTP clients treat 302 as a normal temporary redirect. DBeaver’s AI client does not follow it for completion requests and surfaces it as an error, which is confusing and breaks common gateway / reverse-proxy setups.

Expected behavior

Either:

  1. Follow redirects for AI HTTP calls in a safe way (prefer preserving method/body, e.g. treat like 307, or follow 302/301 without converting POST → GET), or
  2. Keep current non-follow behavior, but show a clear error, e.g.:
    • Received HTTP 302 redirect to <Location>. Set API base URL to the final endpoint (redirects are not followed for POST).

Actual behavior

Any non-200 status is mapped to DBException, including 302, so a simple redirect looks like an OpenAI API failure.

Relevant code path (current devel):

  • MonitoredHttpClient.send() accepts only statusCode == 200, otherwise throws via errorMapper
  • AbstractHttpAIClient uses HttpClient.newHttpClient() (default redirect policy)
  • Java HttpClient with Redirect.NORMAL does not follow 301/302 for POST (completion requests are POST)

Why this matters for custom providers

Custom Base URLs often go through proxies/gateways that return 302 for things like:

  • httphttps
  • trailing slash / path normalization
  • host canonicalization (www / non-www)
  • internal routing in corporate LLM gateways

Users then see a cryptic “OpenAI request failed” even though the service itself is fine once the final URL is used.

Image

DBeaver Version

Community Edition Version 26.1.5.202608161900

Operating System

Debian 13

Database and driver

Not applicable

Steps to reproduce

  1. Configure AI Engine → OpenAI (or compatible)
  2. Set API base URL to an endpoint that answers completion POST with 302 + Location (e.g. HTTP URL that redirects to HTTPS, or a gateway that normalizes the path)
  3. Click Test connection or run AI completion
  4. Observe: OpenAI request failed: HTTP 302

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions