fix: disable httpx proxy for plugin daemon requests#33558
fix: disable httpx proxy for plugin daemon requests#33558hikariming wants to merge 1 commit intolanggenius:mainfrom
Conversation
When running Dify from source on macOS, httpx may attempt to use system proxy settings for localhost requests to plugin daemon, causing connection failures with 'Server disconnected without response'. This fix disables proxy environment variables for internal plugin daemon API calls by setting trust_env=False. Fixes: plugin daemon connection issues in local development environment
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request disables proxy usage for httpx requests made to the plugin daemon by setting trust_env=False. This is intended to fix connection failures on systems with system-wide proxy settings. The changes are applied to both regular and streaming requests in api/core/plugin/impl/base.py. The implementation correctly applies the trust_env=False parameter to the httpx.request and httpx.stream calls.
Pyrefly DiffNo changes detected. |
Problem
When running Dify from source on macOS (or other systems with proxy configurations), httpx may attempt to use system proxy settings for localhost requests to the plugin daemon. This causes connection failures with errors like:
or
Root Cause
The
httpx.request()andhttpx.stream()functions default totrust_env=True, which reads proxy settings from environment variables. Even when system proxy is shown as "disabled" in macOS settings, httpx may still attempt to route localhost traffic through a proxy.Solution
Add
trust_env=Falseparameter to httpx calls for plugin daemon API requests. Since these are internal network calls to localhost, they should never go through a proxy.Testing
Tested locally with:
flask run)Changes
api/core/plugin/impl/base.py: Addedtrust_env=Falsetohttpx.request()andhttpx.stream()calls