{"record":{"id":"90679dd0a5cffcff","repo":"alibaba/spring-ai-alibaba","slug":"nacos-config-content-is-not-valid-json-but-dot-no","errorCode":null,"errorMessage":"Nacos config content is not valid JSON, but dot notation was used. Please ensure the config is in JSON format or remove the dot notation. Content: <jsonString>","messagePattern":"Nacos config content is not valid JSON, but dot notation was used\\. Please ensure the config is in JSON format or remove the dot notation\\. Content: <jsonString>","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-boot-starters/spring-ai-alibaba-starter-config-nacos/src/main/java/com/alibaba/cloud/ai/agent/nacos/tools/NacosMcpGatewayToolCallback.java","lineNumber":258,"sourceCode":"\t\t\t// 根据节点类型返回合适的值\n\t\t\tif (currentNode.isTextual()) {\n\t\t\t\treturn currentNode.asText();\n\t\t\t}\n\t\t\telse if (currentNode.isNumber()) {\n\t\t\t\treturn currentNode.asText();\n\t\t\t}\n\t\t\telse if (currentNode.isBoolean()) {\n\t\t\t\treturn String.valueOf(currentNode.asBoolean());\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// 对于复杂对象，返回JSON字符串\n\t\t\t\treturn currentNode.toString();\n\t\t\t}\n\t\t}\n\t\tcatch (JsonProcessingException e) {\n\t\t\tlogger.error(\"[extractJsonValueFromNacos] Failed to parse JSON from Nacos config. Content: {}, Error: {}\",\n\t\t\t\t\tjsonString, e.getMessage());\n\t\t\tthrow new RuntimeException(\n\t\t\t\t\t\"Nacos config content is not valid JSON, but dot notation was used. Please ensure the config is in JSON format or remove the dot notation. Content: \"\n\t\t\t\t\t\t\t+ jsonString,\n\t\t\t\t\te);\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tlogger.error(\"[extractJsonValueFromNacos] Failed to extract JSON value from Nacos config: {}\",\n\t\t\t\t\te.getMessage(), e);\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\tprivate String processTemplateString(String template, Map<String, Object> params) {\n\t\tMap<String, Object> args = (Map<String, Object>) params.get(\"args\");\n\t\tString extendedData = (String) params.get(\"extendedData\");\n\t\tlogger.debug(\"[processTemplateString] template: {} args: {} extendedData: {}\", template, args, extendedData);\n\t\tif (template == null || template.isEmpty()) {\n\t\t\treturn \"\";\n\t\t}","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-boot-starters/spring-ai-alibaba-starter-config-nacos/src/main/java/com/alibaba/cloud/ai/agent/nacos/tools/NacosMcpGatewayToolCallback.java#L240-L276","documentation":"Thrown by NacosMcpGatewayToolCallback.extractJsonValueFromNacos when a dot-notation path is applied to Nacos config content that cannot be parsed as JSON (JsonProcessingException). The error tells you the referenced config is not JSON, which dot-notation extraction requires; the full content is included in the message.","triggerScenarios":"A placeholder uses dot notation like ${ref:a.b.c} but the Nacos config content for the dataId/group is properties/YAML/plain text, so ObjectMapper fails with JsonProcessingException during extraction.","commonSituations":"Config published to Nacos as .properties while the tool template assumes JSON; accidental trailing characters or BOM breaking JSON; users switching config format without updating placeholders.","solutions":["Re-publish the Nacos config content as valid JSON (check the message for the offending content).","Remove the dot notation from the placeholder if you only need the raw config text.","Validate the config with a JSON parser (e.g. jq) before publishing.","Strip BOM/whitespace from the stored config if it visually looks like JSON but fails to parse."],"exampleFix":"// before (Nacos content)\nuser.name=alice\nuser.role=admin\n// after: publish JSON for dot-notation access\n{\"user\": {\"name\": \"alice\", \"role\": \"admin\"}}","handlingStrategy":"validation","validationCode":"boolean isJson(String s) {\n    try { new ObjectMapper().readTree(s); return true; } catch (Exception e) { return false; }\n}\n// verify the Nacos config parses as JSON before using dot notation\n// assert isJson(nacosConfigContent);","typeGuard":null,"tryCatchPattern":"try {\n    return callback.call(input);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"Nacos config content is not valid JSON\")) {\n        logger.error(\"Re-publish config as JSON or drop dot notation; content was: {}\", e.getMessage());\n    }\n    throw e;\n}","preventionTips":["Publish Nacos configs used with dot notation strictly as JSON.","Lint configs with a JSON parser before publishing to Nacos.","Strip BOM/trailing whitespace that can break parsing."],"tags":["nacos","json","config","parsing"],"backgroundTag":"json-parse-error","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}