{"record":{"id":"6ef23e3d35b9eb97","repo":"spring-projects/spring-ai","slug":"msg-tostring","errorCode":null,"errorMessage":"${msg.toString()}","messagePattern":"\\$\\{msg\\.toString\\(\\)\\}","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"spring-ai-template-st/src/main/java/org/springframework/ai/template/st/CommonsLoggingStErrorListener.java","lineNumber":49,"sourceCode":"\n\tprivate final Log logger;\n\n\t/* package */ CommonsLoggingStErrorListener(Log 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":31,"sourceCodeEnd":64,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/spring-ai-template-st/src/main/java/org/springframework/ai/template/st/CommonsLoggingStErrorListener.java#L31-L64","documentation":"CommonsLoggingStErrorListener is the StringTemplate (ST) error listener used by spring-ai-template-st. When the ST engine raises a runtime error while rendering a template, this listener logs it via Commons Logging: ERROR level for real errors, WARN level for missing-property errors, which are deliberately ignored otherwise. The message text is simply the ST engine's own error description.","triggerScenarios":"Rendering an ST template (e.g. via StTemplateRenderer) that hits a runtime evaluation problem: referencing a property that does not exist on the model object, illegal reflective access on a property, or I/O errors — anything ST reports through RuntimeError.","commonSituations":"Prompt templates referencing variables with wrong property paths (obj.name where model has no 'name'); passing Maps instead of POJOs or vice versa; typos in template placeholders; using records/classes whose fields ST cannot access.","solutions":["Read the logged ST message — it names the template and the exact property or operation that failed.","Fix the placeholder/property path in the template so it matches the variables passed to render().","Verify the model object exposes the referenced properties (public getters/fields accessible to ST).","If the message is a NO_SUCH_PROPERTY warning, either add the missing variable to the model or use StTemplateRenderer validation to catch it upfront."],"exampleFix":"// before: template references property that doesn't exist\nStringTemplate st = new StringTemplate(\"Hello {userName.first}!\"); // model has only 'user'\n// after: align template with model\nStringTemplate st = new StringTemplate(\"Hello {user}!\");","handlingStrategy":"validation","validationCode":"// verify placeholders match model keys before rendering\nSet<String> tokens = extractPlaceholders(template);\nif (!modelMap.keySet().containsAll(tokens)) { throw new IllegalArgumentException(\"unresolved placeholders: \" + tokens); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep template property paths aligned with the actual model object structure.","Render templates in tests with representative model objects.","Use ValidationMode.THROW during development to surface issues early.","Enable the ST error listener logging and check logs in CI."],"tags":["stringtemplate","template-rendering","logging"],"backgroundTag":"template-render-error","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}