{"record":{"id":"fb916024d514d66e","repo":"halo-dev/halo","slug":"exception-loading-messages-file","errorCode":null,"errorMessage":"Exception loading messages file","messagePattern":"Exception loading messages file","errorType":"exception","errorClass":"TemplateInputException","httpStatus":null,"severity":"error","filePath":"application/src/main/java/run/halo/app/theme/message/ThemeMessageResolutionUtils.java","lineNumber":127,"sourceCode":"\n        return resourceNames;\n    }\n\n    private static String getResourceName(String name) {\n        return LOCATION + \"/\" + name + PROPERTIES_FILE_EXTENSION;\n    }\n\n    private static Properties readMessagesResource(final Reader propertiesReader) {\n        if (propertiesReader == null) {\n            return null;\n        }\n        final Properties properties = new Properties();\n        try (propertiesReader) {\n            // Note Properties#load(Reader) this is JavaSE 6 specific, but Thymeleaf 3.0 does\n            // not support Java 5 anymore...\n            properties.load(propertiesReader);\n        } catch (final Exception e) {\n            throw new TemplateInputException(\"Exception loading messages file\", e);\n        }\n        // ignore errors closing\n        return properties;\n    }\n}\n","sourceCodeStart":109,"sourceCodeEnd":133,"githubUrl":"https://github.com/halo-dev/halo/blob/d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8/application/src/main/java/run/halo/app/theme/message/ThemeMessageResolutionUtils.java#L109-L133","documentation":"readMessagesResource() opens a Reader on a theme message properties file and calls Properties.load(reader). If load() throws any exception (malformed file: bad Unicode escape, illegal escape, IO failure mid-read), it is wrapped in a TemplateInputException 'Exception loading messages file' and aborts theme message resolution. A null Reader returns null earlier and does NOT throw, so this error implies the file exists but is unreadable/malformed.","triggerScenarios":"A theme bundles a messages_<lang>.properties (or messages_default.properties) that is present but cannot be parsed: invalid \\u escapes, stray bytes, or an I/O error while reading. Thrown during theme message-bundle resolution for the request locale.","commonSituations":"Hand-edited properties file with a broken escape sequence; file saved as non-Latin1/non-UTF-8 with raw high bytes that break Properties.load; truncated file on disk; file-system read error.","solutions":["Open the offending theme messages_*.properties and fix the malformed escape sequence (the wrapped cause names the line).","Re-save the file as ISO-8859-1 (Properties.load(Reader) expects the Reader's encoding) or valid UTF-8 with proper \\uXXXX escapes for non-ASCII.","Reinstall the theme from a known-good archive if the file got corrupted.","Check filesystem permissions/health if the cause is an IOException."],"exampleFix":"# before (broken unicode escape in messages_en.properties)\n#   greeting = Hello \\u00WorId\n# after\n#   greeting = Hello World","handlingStrategy":"try-catch","validationCode":"// Validate a theme messages file parses before deploying:\nProperties p = new Properties();\ntry (Reader r = Files.newBufferedReader(path)) {\n    p.load(r);\n} catch (Exception e) {\n    throw new IllegalStateException(\"Malformed theme messages file \" + path + \": \" + e.getMessage(), e);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Properties msg = readMessagesResource(reader);\n} catch (TemplateInputException e) {\n    log.error(\"Skipping malformed theme messages file: {}\", e.getCause().getMessage());\n    // fall back to default messages instead of aborting the whole render\n}","preventionTips":["Lint theme messages_*.properties files (escape non-ASCII as \\\\uXXXX) before release.","Save properties files in an encoding compatible with Properties.load(Reader).","Validate theme archives in CI by loading all message bundles.","Keep a known-good default bundle so a malformed locale file can be skipped."],"tags":["theme","i18n","properties","thymeleaf","config"],"backgroundTag":null,"analyzedSha":"d2f5165f9c8f055ffcb3fa9c3f4032821a7b68c8","analyzedAt":"2026-08-14T00:18:38.915Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}