[PR #24164] feat(rag): clarify Unstructured API DNS error when profile service not started #30535

Closed
opened 2026-02-21 20:47:41 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/24164

State: closed
Merged: No


Description: Background
Users encountered opaque “[Errno -2] Name or service not known” errors when UNSTRUCTURED_API_URL points to the docker host name ‘unstructured’ but the corresponding service profile was not started. This led to confusion and unnecessary debugging.

Changes

Added unified exception wrapping in ExtractProcessor for Unstructured ETL DNS failures (socket.gaierror / “[Errno -2]” / “Name or service not known”)
Added actionable guidance: probable causes (profile not enabled, mis-typed URL, network/DNS) and troubleshooting steps (docker compose ps, enabling profile, validating env vars)
Preserved original traceback via exception chaining to avoid hiding root stack
Before (log excerpt)
httpx.ConnectError: [Errno -2] Name or service not known

After (log excerpt)
RuntimeError: Unstructured document extraction failed: unable to resolve or connect to the Unstructured API host.
UNSTRUCTURED_API_URL=http://unstructured:8000/general/v0/general
Possible causes:

'unstructured' service is defined under 'profiles' but the profile was NOT enabled (container never started, so DNS name is unknown).
UNSTRUCTURED_API_URL is misspelled or its DNS record is not resolvable from the container.
Container network / DNS configuration issue.
Troubleshooting steps:
a) docker compose ps | grep unstructured (ensure it shows Up).
b) Inside API container: getent hosts or ping -c1 .
c) Confirm ETL_TYPE=Unstructured and UNSTRUCTURED_API_URL point to the intended host.
d) If using profiles: docker compose --profile unstructured up -d (or remove the 'profiles' line to always start).
Original error: [Errno -2] Name or service not known
Test Plan

Run without starting unstructured profile → upload PPTX → verify enriched message.
Start unstructured profile → verify extraction still succeeds (no new noise).
Set UNSTRUCTURED_API_URL to invalid host → verify same structured guidance applies.
Non-Unstructured ETL_TYPE (dify) path → ensure no behavior change.
Backward Compatibility

No changes to public APIs or return data
Only affects error path for Unstructured ETL_TYPE
Risk / Mitigation

Low: wrapping only DNS-related failures; conservative predicate.
Docs

(Optional) Could add a troubleshooting entry under RAG ingestion errors referencing new message.
Checklist

Code compiles
Added unified error guidance
(Optional) Add unit test simulating DNS failure (mock socket.getaddrinfo)
(Optional) Documentation update

Fix https://github.com/langgenius/dify/issues/24162

**Original Pull Request:** https://github.com/langgenius/dify/pull/24164 **State:** closed **Merged:** No --- Description: Background Users encountered opaque “[Errno -2] Name or service not known” errors when UNSTRUCTURED_API_URL points to the docker host name ‘unstructured’ but the corresponding service profile was not started. This led to confusion and unnecessary debugging. Changes Added unified exception wrapping in ExtractProcessor for Unstructured ETL DNS failures (socket.gaierror / “[Errno -2]” / “Name or service not known”) Added actionable guidance: probable causes (profile not enabled, mis-typed URL, network/DNS) and troubleshooting steps (docker compose ps, enabling profile, validating env vars) Preserved original traceback via exception chaining to avoid hiding root stack Before (log excerpt) httpx.ConnectError: [Errno -2] Name or service not known After (log excerpt) RuntimeError: Unstructured document extraction failed: unable to resolve or connect to the Unstructured API host. UNSTRUCTURED_API_URL=[http://unstructured:8000/general/v0/general](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html) Possible causes: 'unstructured' service is defined under 'profiles' but the profile was NOT enabled (container never started, so DNS name is unknown). UNSTRUCTURED_API_URL is misspelled or its DNS record is not resolvable from the container. Container network / DNS configuration issue. Troubleshooting steps: a) docker compose ps | grep unstructured (ensure it shows Up). b) Inside API container: getent hosts <host> or ping -c1 <host>. c) Confirm ETL_TYPE=Unstructured and UNSTRUCTURED_API_URL point to the intended host. d) If using profiles: docker compose --profile unstructured up -d (or remove the 'profiles' line to always start). Original error: [Errno -2] Name or service not known Test Plan Run without starting unstructured profile → upload PPTX → verify enriched message. Start unstructured profile → verify extraction still succeeds (no new noise). Set UNSTRUCTURED_API_URL to invalid host → verify same structured guidance applies. Non-Unstructured ETL_TYPE (dify) path → ensure no behavior change. Backward Compatibility No changes to public APIs or return data Only affects error path for Unstructured ETL_TYPE Risk / Mitigation Low: wrapping only DNS-related failures; conservative predicate. Docs (Optional) Could add a troubleshooting entry under RAG ingestion errors referencing new message. Checklist Code compiles Added unified error guidance (Optional) Add unit test simulating DNS failure (mock socket.getaddrinfo) (Optional) Documentation update Fix https://github.com/langgenius/dify/issues/24162
yindo added the pull-request label 2026-02-21 20:47:41 -05:00
yindo closed this issue 2026-02-21 20:47:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#30535