fix(im): render resource:// images in IM channels (nginx /r/ + config guards) - #2352
Merged
lyingbug merged 1 commit intoJul 28, 2026
Merged
Conversation
… guards)
IM channels (DingTalk/Feishu) showed broken images because resource://
image references resolve to WeKnora capability links that were neither
reachable nor renderable:
- nginx never proxied /r/, so <APP_EXTERNAL_URL>/r/<token> links fell into
the SPA fallback and returned a blank page. Add a /r/ proxy block
mirroring /files, using the ${APP_SCHEME}/${APP_HOST}/${APP_PORT} vars.
- rewriteStorageURLs treated any "dst != src" as success and emitted
non-HTTP results (e.g. an internal storage:// path when APP_EXTERNAL_URL
is unset) that IM clients cannot fetch. Only substitute http(s) URLs;
otherwise leave the reference unchanged and log an actionable WARN.
- Warn once at startup when IM channels are active but APP_EXTERNAL_URL is
unset — the config state that silently breaks resource:// images on the
default MinIO/local deployment.
- Document that IM knowledge-base images need an IM-reachable http URL via
one of two paths: a publicly reachable storage backend, or APP_EXTERNAL_URL
routing resource:// through nginx /r/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
IM channels (DingTalk / Feishu / etc.) rendered blank/broken images when an answer contained knowledge‑base images. These images are carried as
resource://<handle>references that resolve to WeKnora capability links (<APP_EXTERNAL_URL>/r/<token>), which were neither reachable nor rendered:/r/./r/<token>links fell through into the SPAtry_files … /index.htmlfallback and returned a blank HTML page, so the image never loaded. This is the root cause of the reported issue.rewriteStorageURLstreated anydst != srcas success. WhenAPP_EXTERNAL_URLwas unset, aresource://alias could resolve to an internalstorage://…path, which was then emitted verbatim to the IM client (unfetchable).Changes
frontend/nginx.conf: add alocation ^~ /r/proxy block mirroring/filesand/api/(same${APP_SCHEME}/${APP_HOST}/${APP_PORT}vars and forwarding headers), so capability links reach the backend instead of the SPA fallback.internal/im/service.go: only substitute anhttp(s)result inrewriteStorageURLs(viaisHTTPResolvedURL, case‑insensitive per RFC 3986); otherwise leave the reference unchanged and log an actionable WARN. Add a one‑time startup WARN when IM channels are active butAPP_EXTERNAL_URLis unset — the config state that silently breaksresource://images on the default MinIO/local deployment..env.example,docker-compose.yml,docs/IM集成开发文档.md): document that IM knowledge‑base images need an IM‑reachable HTTP URL via one of two paths — (A) a publicly reachable storage backend (e.g. object storage with a public endpoint, orMINIO_ENDPOINTset to a public host), or (B) setAPP_EXTERNAL_URLsoresource://routes through nginx/r/. The default MinIO deployment (internalminio:9000) uses path (B).Type of Change
Related Issue
Fixes #2277
Testing
TestRewriteStorageURLs_NonHTTPResultIsNoOpandTestRewriteStorageURLs_UppercaseSchemeIsSubstituted(guard behavior), andTestIMImageConfigWarning(startup warning matrix).gofmt -l,go vet ./internal/im/,go build ./internal/im/..., andgo test ./internal/im/all pass locally. The change is IM‑scoped; the fullmake testsuite was not run locally.mainwith no conflicts; our changes (URL rewrite + startup config warning) touch a different code region than the connection‑lifecycle refactors.Checklist
gofmt/go vet/go build/go test ./internal/im/pass locally (fullmake testnot run — change is IM‑scoped).env.example,docker-compose.yml,docs/)