HMCL-dev/HMCL · error · JsonParseException

Unsupported protected payload:

Error message

Unsupported protected payload: 

What it means

After reading the 'protection' member, fromEnvelope iterates all ProtectionMode values and returns the one whose id matches. If no enum constant matches the declared id, it throws JsonParseException, meaning the envelope declares a protection mode this HMCL build does not support.

Solutions

  1. Use an HMCL version that supports the declared protection mode (upgrade HMCL)
  2. Correct the 'protection' id to a value supported by this build (inspect ProtectionMode.values() ids)
  3. Regenerate the envelope with the current library so it writes a supported mode
  4. Catch JsonParseException and treat the payload as unrecoverable, prompting re-entry of the secret

Example fix

// before
{"protection":"quantum-sealed","payload":"..."}
// after
{"protection":"none","payload":"..."}
Defensive patterns

Strategy: try-catch

Validate before calling

String p = JsonUtils.getString(envelope, PROPERTY_PROTECTION); if (p != null && Arrays.stream(ProtectionMode.values()).noneMatch(m -> m.id.equals(p))) { throw new IllegalArgumentException("unsupported protection: " + p); }

Try / catch

try { mode = ProtectionMode.fromEnvelope(envelope); } catch (JsonParseException e) { LOG.warning("Unsupported protection mode: " + e.getMessage(), e); }

Prevention

When it happens

Trigger: Envelopes whose 'protection' member contains an unknown id — e.g. produced by a newer HMCL version, corrupted by manual editing, or containing a typo.

Common situations: Downgrading HMCL to an older release that predates the protection mode; hand-editing the protection id; file corruption.

Related errors


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

Appendix: source

Thrown at HMCL/src/main/java/org/jackhuang/hmcl/setting/ProtectedPayload.java:347

        }

        /// Reads the protection mode from an envelope.
        ///
        /// @param envelope the envelope object to inspect
        /// @return the protection mode declared by the envelope
        /// @throws JsonParseException if the declared protection mode is unsupported
        static ProtectionMode fromEnvelope(JsonObject envelope) {
            String protection = JsonUtils.getString(envelope, PROPERTY_PROTECTION);
            if (protection == null) {
                throw new JsonParseException("Missing protected payload member: protection");
            }

            for (ProtectionMode mode : values()) {
                if (mode.id.equals(protection)) {
                    return mode;
                }
            }
            throw new JsonParseException("Unsupported protected payload: " + protection);
        }
    }

    /// Reads and reveals a protected JSON payload from an envelope object.
    ///
    /// @param envelope the envelope object to read from
    /// @param payloadType the expected JSON element type
    /// @return the revealed JSON payload
    /// @param <T> the expected JSON element type
    /// @throws JsonParseException if the envelope is malformed or cannot be revealed
    static <T extends JsonElement> T read(JsonObject envelope, Class<T> payloadType) throws JsonParseException {
        return ProtectionMode.fromEnvelope(envelope).read(envelope, payloadType);
    }

}

View on GitHub (pinned to 24702dc5a0)