HMCL-dev/HMCL · error · JsonParseException

FileInformation missing file hash code.

Error message

FileInformation missing file hash code.

What it means

ModpackConfiguration.FileInformation.validate() throws JsonParseException when a file entry lacks a `hash` value. The hash lets HMCL verify downloaded files against the modpack manifest. Validation enforces both path and hash on every entry.

Solutions

  1. Add the correct SHA-1 hash for each file entry in the configuration JSON
  2. Re-export the modpack so hashes are computed automatically
  3. Remove entries whose files no longer exist in the pack

Example fix

// before
{"files":[{"path":"mods/foo.jar"}]}
// after
{"files":[{"path":"mods/foo.jar","hash":"1a2b3c..."}]}
Defensive patterns

Strategy: validation

Validate before calling

if (info.getHash() == null) throw new IllegalArgumentException("FileInformation missing hash: " + info.getPath());

Type guard

boolean hasHash(FileInformation f) { return f != null && f.getHash() != null; }

Try / catch

try { fileInformation.validate(); } catch (JsonParseException e) { log.error("Entry without hash", e); }

Prevention

When it happens

Trigger: Deserializing a modpack configuration whose files[] entry has a null `hash`, then calling validate().

Common situations: Modpack exported by a tool that omits hashes, truncated or hand-edited config files, or entries manually appended without computing the file hash.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of HMCL-dev/HMCL@24702dc5a0 (2026-09-10). Data as JSON: /api/errors/a07759cb6dd5f5b2. Report an issue: GitHub.

Appendix: source

Thrown at HMCLCore/src/main/java/org/jackhuang/hmcl/modpack/ModpackConfiguration.java:139

         */
        public String getPath() {
            return path;
        }

        public String getDownloadURL() {
            return downloadURL;
        }

        public String getHash() {
            return hash;
        }

        @Override
        public void validate() throws JsonParseException {
            if (path == null)
                throw new JsonParseException("FileInformation missing `path`.");
            if (hash == null)
                throw new JsonParseException("FileInformation missing file hash code.");
        }
    }
}

View on GitHub (pinned to 24702dc5a0)