Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 15, 2025

FileURLService hardcoded http://localhost:8000 as default base_url, causing remote MinerU API to fail in Docker environments where localhost is unreachable.

Changes

  • FileURLService.__init__: Remove hardcoded default, require FILE_SERVICE_BASE_URL env var
  • get_file_service(): Delegate env var handling to __init__ instead of duplicating logic
  • env.example: Update FILE_SERVICE_BASE_URL with clear "must configure" warning and placeholder value http://your-ip:8000 instead of localhost

Behavior

# Before: silently uses localhost (breaks in Docker)
service = FileURLService()  # base_url = "http://localhost:8000"

# After: fails fast with clear error if env var not set
service = FileURLService()
# ValueError: FILE_SERVICE_BASE_URL 环境变量未设置。
# 请在 .env 文件中配置 FILE_SERVICE_BASE_URL=http://your-ip:8000

Explicit base_url parameter still works for testing/override scenarios.

Original prompt

This section details on the original issue you should resolve

<issue_title>File service URL hardcoded to localhost breaks Docker deployment</issue_title>
<issue_description>## 问题描述
文件服务 URL 硬编码为 localhost,导致 Docker 部署失败。在 Docker 环境中 localhost 无法访问,远程 MinerU API 无法获取文件。

受影响的文件

  • src/file_url_service.py 行 21, 141

硬编码值

问题

虽然有正确的环境变量 FILE_SERVICE_BASE_URL,但被硬编码的默认值覆盖。

解决方案

应该移除硬编码的默认值,强制从环境变量读取。</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove hardcoded localhost URL from file service Fix hardcoded localhost URL in FileURLService breaking Docker deployment Dec 15, 2025
Copilot AI requested a review from BukeLy December 15, 2025 09:43
Comment on lines -21 to +29
def __init__(self, base_url: str = "http://localhost:8000",
def __init__(self, base_url: Optional[str] = None,
temp_dir: str = "/tmp/rag-files"):
# 从环境变量读取 base_url,移除硬编码默认值
base_url = base_url or os.getenv("FILE_SERVICE_BASE_URL")
if not base_url:
raise ValueError(
"FILE_SERVICE_BASE_URL 环境变量未设置。"
"请在 .env 文件中配置 FILE_SERVICE_BASE_URL=http://your-ip:8000"
)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有在 .env.example 中添加示例 @copilot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已更新 env.example,添加了 FILE_SERVICE_BASE_URL 的必须配置说明,并将默认值从 localhost 改为 your-ip 占位符,避免误用。(35e94f5)

Co-authored-by: BukeLy <19304666+BukeLy@users.noreply.github.com>
Copilot AI requested a review from BukeLy December 15, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File service URL hardcoded to localhost breaks Docker deployment

2 participants