AI Validation Fails with Open AI-Compatible endpoint

Open
#401 7 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
javascript
Domain
api, backend

Research direction

Start by finding the backend handler that tests AI providers and the code that sends the OpenAI-compatible chat completion request; compare its request and redirect handling with the working cURL example in the issue. Reproduce the failure against an OpenAI-compatible endpoint that redirects, then confirm the provider test succeeds and its existing failure cases still behave correctly.

Written by the indexing model from the issue text.

Description

Describe the bug
I'm trying to use a cloud-based AI provider that is Open AI-compatible, but the test fails when I try to add it via the MailFlow settings panel. The provider I'm testing with is "The Grid" (https://thegrid.ai).

Observed behaviors:

  • In the UI, I get the response: "Connection failed: AI provider test failed"
  • Nothing shows in the backend or frontend Docker containers
  • In the browser DevTools I get 502 Bad Gateway and the JSON response, {"error":"AI provider test failed"}

This cUrl POST request from a CLI works fine:

curl -L -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer my_api_key_here" \
  -d '{
    "model": "text-standard",
    "messages": [{"role": "user", "content": "Hello!"}],
    "max_tokens": 50
  }' \
  https://api.thegrid.ai/v1/chat/completions

... which yields a response like this:

{"choices":[{"finish_reason":"stop","index":0,"message":{"content":"Hello! 👋 How can I assist you today?","provider_specific_fields":{"name":null,"refusal":null},"reasoning_content":"The user says \"Hello!\" Likely a greeting. We should respond politely. Ask how can help.","role":"assistant"},"provider_specific_fields":{}}],"created":1787572938,"id":"chatcmpl-RMAk1dOyKsGC3w7pr5veLClx","model":"openai/gpt-oss-120b","object":"chat.completion","service_tier":"default","usage":{"completion_tokens":42,"estimated_cost":9.212000000000001e-6,"prompt_tokens":56,"total_tokens":98}}

Possibly-related information:

  • If I do the above curl test from a CLI WITHOUT the -L (adding this allows curl to follow redirects), I get an HTML response saying I'm being redirected -- so I SUSPECT whatever test MailFlow is doing may not be following redirects, and hence it is not getting a valid response, and is interpreting it as a failure.
Dominant language
JavaScript
Stars
518
Forks
50
Avg merge
4d 45m
Merged PRs (30d)
43

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from maathimself/mailflow

All issues in maathimself/mailflow

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.