Skip to content

fix: Fallback to request host url when CONSOLE_API_URL is empty for O…#36848

Open
04AvinashSingh wants to merge 16 commits into
langgenius:mainfrom
04AvinashSingh:fix/36833-oauth-callback-url-fallback
Open

fix: Fallback to request host url when CONSOLE_API_URL is empty for O…#36848
04AvinashSingh wants to merge 16 commits into
langgenius:mainfrom
04AvinashSingh:fix/36833-oauth-callback-url-fallback

Conversation

@04AvinashSingh
Copy link
Copy Markdown

Fixes langgenius/dify-official-plugins#3238

Summary

Self-hosted users deploying via docker-compose encounter OAuth failures (e.g., SharePoint AADSTS90102) because CONSOLE_API_URL defaults to empty, resulting in relative callback URIs being sent to the identity provider.

This PR adds a get_console_api_url() helper that gracefully falls back to request.host_url when the environment variable is blank. It updates all trigger, plugin, SSO, and tool callback generators to use this helper, ensuring absolute URLs are reliably generated right out of the box without requiring manual .env configuration.

Screenshots

N/A - Backend API fix for OAuth URL generation. No UI changes.

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

…Auth callbacks

Resolves #36833

Self-hosted users deploying via docker-compose encounter OAuth failures (e.g., SharePoint AADSTS90102) because CONSOLE_API_URL defaults to empty, resulting in relative callback URIs.

Added a get_console_api_url() helper that gracefully falls back to request.host_url when the environment variable is blank. Updated all trigger, plugin, SSO, and tool callback generators to use this absolute URL helper.
@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label May 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-06-01 11:56:01.653711637 +0000
+++ /tmp/pyrefly_pr.txt	2026-06-01 11:55:47.883584381 +0000
@@ -67,7 +67,7 @@
 ERROR Class member `PluginToolProviderController.entity` overrides parent class `BuiltinToolProviderController` in an inconsistent manner [bad-override-mutable-attribute]
   --> core/tools/plugin_tool/provider.py:12:5
 ERROR Cannot set item in `dict[str, dict[str, Any]]` [unsupported-operation]
-    --> core/tools/tool_manager.py:1110:58
+    --> core/tools/tool_manager.py:1111:58
 ERROR `(method: str, url: str, max_retries: int = ..., **kwargs: Any) -> httpx._models.Response` is not assignable to attribute `perform_request` with type `(self: CloudScraper, method: Unknown, url: Unknown, *args: Unknown, **kwargs: Unknown) -> requests.models.Response` [bad-assignment]
   --> core/tools/utils/web_reader_tool.py:66:35
 ERROR `list[Never]` is not assignable to attribute `tools` with type `Never` [bad-assignment]
@@ -557,7 +557,7 @@
 ERROR Object of class `Tenant` has no attribute `role` [missing-attribute]
     --> services/account_service.py:1383:13
 ERROR `+` is not supported between `str` and `dict[Unknown, Unknown]` [unsupported-operation]
-   --> services/app_service.py:519:53
+   --> services/app_service.py:520:53
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
    --> services/audio_service.py:144:56
 ERROR No matching overload found for function `flask.helpers.stream_with_context` called with arguments: (Generator[bytes]) [no-matching-overload]
@@ -4178,6 +4178,8 @@
    --> tests/unit_tests/core/datasource/utils/test_message_transformer.py:329:26
 ERROR Argument `SimpleNamespace` is not assignable to parameter `db_provider` with type `MCPToolProvider` in function `core.entities.mcp_provider.MCPProviderEntity.from_db_model` [bad-argument-type]
   --> tests/unit_tests/core/entities/test_entities_mcp_provider.py:59:46
+ERROR No attribute `dify_config` in module `core.entities.mcp_provider` [missing-attribute]
+  --> tests/unit_tests/core/entities/test_entities_mcp_provider.py:70:25
 ERROR `None` is not subscriptable [unsupported-operation]
    --> tests/unit_tests/core/entities/test_entities_provider_configuration.py:666:12
 ERROR Argument `SimpleNamespace` is not assignable to parameter `credential_record` with type `ProviderCredential | ProviderModelCredential` in function `core.entities.provider_configuration.ProviderConfiguration._update_load_balancing_configs_with_credential` [bad-argument-type]

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 45.98% 45.98% +0.00%
Strict coverage 45.49% 45.49% +0.00%
Typed symbols 24,871 24,872 +1
Untyped symbols 29,534 29,534 0
Modules 2770 2770 0

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 1, 2026
@04AvinashSingh 04AvinashSingh requested a review from laipz8200 as a code owner June 4, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sharepoint Plugin does not create full URI callback_uri attribute when authenticating with EntraID OAuth

1 participant