{"record":{"id":"62d993854f71a77c","repo":"alibaba/spring-ai-alibaba","slug":"msg-tostring","errorCode":null,"errorMessage":"msg.toString()","messagePattern":"msg\\.toString\\(\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/renderer/Slf4jStErrorListener.java","lineNumber":47,"sourceCode":"\n\tprivate final Logger logger;\n\n\t/* package */ Slf4jStErrorListener(Logger logger) {\n\t\tthis.logger = logger;\n\t}\n\n\t@Override\n\tpublic void compileTimeError(STMessage msg) {\n\t\tlogger.error(msg.toString());\n\t}\n\n\t@Override\n\tpublic void runTimeError(STMessage msg) {\n\t\tif (msg.error != ErrorType.NO_SUCH_PROPERTY) { // ignore these\n\t\t\tlogger.error(msg.toString());\n\t\t}\n\t\telse {\n\t\t\tlogger.warn(msg.toString());\n\t\t}\n\t}\n\n\t@Override\n\tpublic void IOError(STMessage msg) {\n\t\tlogger.error(msg.toString());\n\t}\n\n\t@Override\n\tpublic void internalError(STMessage msg) {\n\t\tlogger.error(msg.toString());\n\t}\n\n}\n","sourceCodeStart":29,"sourceCodeEnd":62,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-agent-framework/src/main/java/com/alibaba/cloud/ai/graph/agent/renderer/Slf4jStErrorListener.java#L29-L62","documentation":"Slf4jStErrorListener is the StringTemplate (ST) error listener wired into template rendering. On a runtime ST error it logs msg.toString() — this is the literal message text surfaced in logs, e.g. 'context ... no such property' or 'no such attribute'. NO_SUCH_PROPERTY errors are downgraded to warn (they are usually benign, e.g. optional fields); all other runtime errors are logged at error level. Rendering proceeds; the listener does not throw.","triggerScenarios":"runTimeError is invoked by the ST engine while evaluating a rendered template: referencing an attribute that doesn't exist (other than the ignored NO_SUCH_PROPERTY case), invoking a malformed expression, or an incompatible renderer/converter — msg.toString() is what appears in your log.","commonSituations":"1) Template references a key absent from the model (typo or renamed field) that isn't caught by NO_SUCH_PROPERTY filtering. 2) Iterating a null collection inside a template. 3 Passing a value whose type has no registered ST renderer (e.g. LocalDate without an AttributeRenderer). 4 Reading these messages in noisy logs and wanting to promote/demote them.","solutions":["Parse the msg.toString() text to identify the offending template expression/property, then fix the template or supply the missing attribute in the model.","Register an ST AttributeRenderer for custom types (dates, enums) used in templates.","Null-guard data before rendering (empty lists instead of null) to avoid iteration errors.","If NO_SUCH_PROPERTY noise dominates, tighten templates to the actual model or pre-validate with SaaStTemplateRenderer validation mode THROW."],"exampleFix":"// before\ntemplate.add(\"createdAt\", entity.getCreatedAt()); // LocalDate, no renderer -> ST runtime error\n// after\nst.add(\"createdAt\", entity.getCreatedAt() == null ? \"\" : entity.getCreatedAt().format(DateTimeFormatter.ISO_DATE));","handlingStrategy":"try-catch","validationCode":"static void validateModel(ST st, Set<String> expectedKeys) {\n    Map<String, Object> attrs = st.getAttributes();\n    for (String k : expectedKeys) {\n        if (!attrs.containsKey(k)) throw new IllegalArgumentException(\"Missing ST attribute: \" + k);\n    }\n}","typeGuard":null,"tryCatchPattern":"String rendered;\ntry {\n    rendered = st.render();\n} catch (Exception e) {\n    log.error(\"ST render failed: {}\", e.getMessage(), e);\n    rendered = templateFallback;\n}","preventionTips":["Keep template expressions aligned with the model's attribute names","Pass empty collections instead of null for iterated attributes","Register AttributeRenderers for custom types (dates, enums)","Run render in tests with the error listener enabled to surface issues early"],"tags":["string-template","template-rendering","logging","st4"],"backgroundTag":"unexpected-api-response-shape","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"}