Allow cleartext HTTP for user-supplied local OpenAI-compatible endpoints (and surface model-list errors)

未关闭
#2,887 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
54/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
android, kotlin
领域
ai, mobile, networking

调研方向

Start with app/src/main/AndroidManifest.xml and app/src/debug/AndroidManifest.xml to compare release and debug network policies, then inspect AiConfigScreen.kt where openAIModels errors switch to manual input. Decide how user-supplied HTTP endpoints should be permitted and show the model-list error; done means release builds can use the intended local endpoint policy and users see an actionable error when model loading fails. Check the issue thread for maintainer guidance before choosing the security scope.

由索引模型根据 Issue 内容生成。

描述

What happened

I'm using the "OpenAI compatible API" AI backend with a gateway running on the phone itself: http://127.0.0.1:7863/v1/. The endpoint is healthy — curl http://127.0.0.1:7863/v1/models returns 200 with 16 models — but in the app the model picker stays on "Loading models…" forever, and no error is ever shown.

Root cause

app/src/main/AndroidManifest.xml declares <application> without android:usesCleartextTraffic and without android:networkSecurityConfig. With targetSdk = compileSdk (37), Android 9+ blocks cleartext HTTP by default, so OkHttp fails at connect time with:

java.net.UnknownServiceException: CLEARTEXT communication to 127.0.0.1 not permitted by network security policy

The only place that permits cleartext for 127.0.0.1 is the debug variant (app/src/debug/AndroidManifest.xml → @xml/webview_test_network_security_config), and its comment explicitly says the release policy is unchanged. So release builds (Play / F-Droid / GitHub) can never reach a local http:// endpoint.

The second half of the problem is that this failure is invisible: in AiConfigScreen.kt, shouldShowManualModelInput becomes true on UiState.Error, which replaces the dropdown with a manual text field and renders no error text. From the user's point of view the model list simply never loads, which reads as a hang rather than a policy rejection.

Why this matters

Running the model endpoint on-device (or on the LAN) is a normal setup: local gateways, Ollama, LM Studio, llama.cpp server, mobile-hosted proxies. All of them are plain http:// by default, and none of them can be reached from a release build.

What I'd like
  1. Primary: let a user-supplied endpoint use cleartext HTTP. Options, in order of preference:
    • add a networkSecurityConfig in the release manifest that permits cleartext for localhost / 127.0.0.1 (and optionally 10.0.2.2 / private ranges) — narrow scope, no global usesCleartextTraffic;
    • or gate it behind an explicit opt-in setting (e.g. "allow insecure connections for this endpoint") next to the server URL field;
    • or, if you'd rather not permit cleartext at all, at least document it in the AI settings screen ("HTTPS required").
  2. Secondary (independent, cheap): surface the actual error when openAIModels is UiState.Error instead of silently switching to manual input. Right now a cleartext block, a 401, a wrong path and a dead server are all indistinguishable from a hang. Even one line of text would have saved me a lot of guessing.
Environment
  • Flare 1.8.0 (Play Store build), Android 13 (API 33), HyperOS
  • AI backend: OpenAI compatible API, server URL http://127.0.0.1:7863/v1/, API key supplied
  • The same endpoint works from curl on the same device
Workaround for anyone hitting this

Use a client that allows cleartext custom endpoints, build a debug variant yourself (debug already whitelists 127.0.0.1), or put the endpoint behind a real HTTPS tunnel with a publicly trusted certificate.

主要语言
Kotlin
星标
1.7k
派生
85
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DimensionDev/Flare 的其他 Issue

查看 DimensionDev/Flare 的全部 Issue

相似的 Issue

更多 Kotlin Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。