langgenius/dify · error · RuntimeError
Failed to parse config: {e}
Error message
Failed to parse config: {e} What it means
Raised by NacosSettingsSource._parse_config when parse_config(content) throws — i.e. the Nacos config payload could not be parsed into a key=value mapping (the default dataId expects Java .properties format). Wrapped as RuntimeError with the underlying exception message.
Source
Thrown at api/configs/remote_settings_sources/nacos/__init__.py:42
data_id = os.getenv("DIFY_ENV_NACOS_DATA_ID", "dify-api-env.properties")
group = os.getenv("DIFY_ENV_NACOS_GROUP", "nacos-dify")
tenant = os.getenv("DIFY_ENV_NACOS_NAMESPACE", "")
params = {"dataId": data_id, "group": group, "tenant": tenant}
try:
content = NacosHttpClient().http_request("/nacos/v1/cs/configs", method="GET", headers={}, params=params)
self.remote_configs = self._parse_config(content)
except Exception:
logger.exception("[get-access-token] exception occurred")
raise
def _parse_config(self, content: str) -> dict[str, str]:
if not content:
return {}
try:
return parse_config(content)
except Exception as e:
raise RuntimeError(f"Failed to parse config: {e}")
@override
def get_field_value(self, field: FieldInfo, field_name: str) -> tuple[Any, str, bool]:
field_value = self.remote_configs.get(field_name)
if field_value is None:
return None, field_name, False
return field_value, field_name, False
View on GitHub (pinned to ef8544b173)
Solutions
- Ensure the Nacos config referenced by DIFY_ENV_NACOS_DATA_ID is in Java .properties format.
- Verify DIFY_ENV_NACOS_GROUP and DIFY_ENV_NACOS_NAMESPACE resolve to the intended config.
- Open the dataId in the Nacos console and confirm it parses as key=value lines.
- Check Nacos HTTP response is 200 with properties body, not an error page.
Example fix
// before
# Nacos dataId content:
spring:
datasource:
url: jdbc:...
// after
# Nacos dataId content (properties):
DB_USERNAME=dify
DB_PASSWORD=dify
SQLALCHEMY_DATABASE_URI=postgresql://dify:dify@db:5432/dify Defensive patterns
Strategy: try-catch
Validate before calling
from configs.remote_settings_sources.nacos.utils import parse_config
def nacos_content_parses(content: str) -> bool:
try:
parse_config(content)
return True
except Exception:
return False Try / catch
try:
source = NacosSettingsSource(configs)
except RuntimeError as e:
logger.exception('Nacos config parse failed: %s', e)
raise Prevention
- Store Nacos config dataId in Java .properties format.
- Confirm DIFY_ENV_NACOS_GROUP and NAMESPACE resolve to the right config.
- Smoke-test parse_config against the live payload during deploy.
When it happens
Trigger: Nacos returns YAML/JSON/toml content for the configured dataId while parse_config expects properties format, or the payload is malformed/truncated.
Common situations: DIFY_ENV_NACOS_DATA_ID pointing at a non-properties config, group/namespace mismatch returning unrelated content, or Nacos returning an HTML error page.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- remote configs is not dict, but {type(self.remote_configs)}
- bad YAML format
- Qdrant URL is required.
- KNOWLEDGE_FS_BASE_URL must be an absolute HTTP(S) URL
- KNOWLEDGE_FS_BASE_URL must include a valid port
AI-assisted analysis of langgenius/dify@ef8544b173 (2026-08-12).
Data as JSON: /api/errors/47ae0af746d3624b.
Report an issue: GitHub.