{"record":{"id":"472a71e4d2726337","repo":"langgenius/dify","slug":"remote-configs-is-not-dict-but-type-self-remote","errorCode":null,"errorMessage":"remote configs is not dict, but {type(self.remote_configs)}","messagePattern":"remote configs is not dict, but (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"api/configs/remote_settings_sources/apollo/__init__.py","lineNumber":54,"sourceCode":"    )\n\n\nclass ApolloSettingsSource(RemoteSettingsSource):\n    def __init__(self, configs: Mapping[str, Any]):\n        self.client = ApolloClient(\n            app_id=configs[\"APOLLO_APP_ID\"],\n            cluster=configs[\"APOLLO_CLUSTER\"],\n            config_url=configs[\"APOLLO_CONFIG_URL\"],\n            start_hot_update=False,\n            _notification_map={configs[\"APOLLO_NAMESPACE\"]: -1},\n        )\n        self.namespace = configs[\"APOLLO_NAMESPACE\"]\n        self.remote_configs = self.client.get_all_dicts(self.namespace)\n\n    @override\n    def get_field_value(self, field: FieldInfo, field_name: str) -> tuple[Any, str, bool]:\n        if not isinstance(self.remote_configs, dict):\n            raise ValueError(f\"remote configs is not dict, but {type(self.remote_configs)}\")\n        field_value = self.remote_configs.get(field_name)\n        return field_value, field_name, False\n","sourceCodeStart":36,"sourceCodeEnd":57,"githubUrl":"https://github.com/langgenius/dify/blob/ef8544b173fd6cd7a8e71df2cab576e52bebbfbc/api/configs/remote_settings_sources/apollo/__init__.py#L36-L57","documentation":"Raised by ApolloSettingsSource.get_field_value when self.remote_configs (populated from ApolloClient.get_all_dicts) is not a dict. This indicates the Apollo server returned an unexpected payload shape (e.g. a list, None, or an error body) rather than a per-namespace config mapping.","triggerScenarios":"Apollo namespace misconfigured, Apollo server returns an error JSON or non-dict object, or get_all_dicts returns None due to a transport/parse issue internal to the client.","commonSituations":"Wrong APOLLO_NAMESPACE, Apollo cluster mismatch, network proxy rewriting the response, or an Apollo version that returns a different schema.","solutions":["Verify APOLLO_APP_ID, APOLLO_CLUSTER, APOLLO_CONFIG_URL, and APOLLO_NAMESPACE match the Apollo project.","Hit APOLLO_CONFIG_URL directly and confirm the namespace returns a JSON object.","Check Apollo server logs / network for non-200 or transformed payloads.","Ensure no proxy is stripping or re-wrapping the response body."],"exampleFix":"// before\nAPOLLO_NAMESPACE=wrong-namespace\n// after\nAPOLLO_NAMESPACE=dify-application\n// (confirm GET {APOLLO_CONFIG_URL}/configs/{app_id}/{cluster}/{namespace} returns a JSON object)","handlingStrategy":"try-catch","validationCode":"from urllib.request import urlopen\nimport json\n\ndef apollo_namespace_is_dict(config_url: str, app_id: str, cluster: str, namespace: str) -> bool:\n    url = f'{config_url.rstrip(\"/\")}/configs/{app_id}/{cluster}/{namespace}'\n    with urlopen(url, timeout=5) as r:\n        body = json.loads(r.read().decode())\n    return isinstance(body, dict) and isinstance(body.get('configurations', {}), dict)","typeGuard":"def is_config_dict(value) -> bool:\n    return isinstance(value, dict)","tryCatchPattern":"try:\n    source = ApolloSettingsSource(configs)\nexcept (ValueError, RuntimeError):\n    logger.exception('Apollo remote config unavailable; falling back to local settings')\n    source = None","preventionTips":["Verify APOLLO_NAMESPACE exists and returns JSON before boot.","Pin Apollo client/server versions that agree on the response schema.","Provide a local-settings fallback path when remote config is unreachable."],"tags":["config","apollo","remote-settings","runtime"],"backgroundTag":null,"analyzedSha":"ef8544b173fd6cd7a8e71df2cab576e52bebbfbc","analyzedAt":"2026-08-12T05:15:17.394Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}