{"record":{"id":"c64791ccdd0be56a","repo":"HMCL-dev/HMCL","slug":"unsupported-operation","errorCode":null,"errorMessage":"Unsupported Operation","messagePattern":"Unsupported Operation","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"warning","filePath":"HMCLCore/src/main/java/org/jackhuang/hmcl/auth/Account.java","lineNumber":97,"sourceCode":"     * Login with stored credentials.\n     *\n     * @throws CredentialExpiredException when the stored credentials has expired, in which case a password login will be performed\n     */\n    public abstract AuthInfo logIn() throws AuthenticationException;\n\n    /**\n     * Play offline.\n     *\n     * @return the specific offline player's info.\n     */\n    public abstract AuthInfo playOffline() throws AuthenticationException;\n\n    public boolean canUploadSkin() {\n        return false;\n    }\n\n    public void uploadSkin(boolean isSlim, Path file) throws AuthenticationException, UnsupportedOperationException {\n        throw new UnsupportedOperationException(\"Unsupported Operation\");\n    }\n\n    /// Writes public account metadata into the target JSON object.\n    ///\n    /// Metadata is stored in `accounts.json` and must not contain credentials or cached private profile data.\n    ///\n    /// The target object is owned by the caller. Implementations may only mutate it during this method call and must\n    /// not retain a reference to it.\n    @MustBeInvokedByOverriders\n    public void writeMetadata(JsonObject metadata) {\n        metadata.addProperty(PROPERTY_ACCOUNT_ID, accountID.toString());\n    }\n\n    /// Writes private account data into the target JSON object.\n    ///\n    /// Private data is stored outside `accounts.json` and may contain credentials or cached profile data.\n    ///\n    /// The target object is owned by the caller. Implementations may only mutate it during this method call and must","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/HMCL-dev/HMCL/blob/24702dc5a0214034f4c27166d5fd30cad08cec19/HMCLCore/src/main/java/org/jackhuang/hmcl/auth/Account.java#L79-L115","documentation":"Account.uploadSkin is the default account implementation and intentionally does not support skin uploading; accounts that cannot upload skins return false from canUploadSkin(). Calling uploadSkin on such an account unconditionally throws UnsupportedOperationException. Subclasses override both methods to provide real skin upload support.","triggerScenarios":"Calling account.uploadSkin(isSlim, file) on any Account whose canUploadSkin() returns false, i.e. account types without skin upload capability (e.g. offline accounts).","commonSituations":"Trying to upload a skin for an offline/unauthenticated account; UI code not checking canUploadSkin before enabling the skin upload action; new account types not yet overriding uploadSkin.","solutions":["Check account.canUploadSkin() before calling uploadSkin and hide/disable the feature when false","Only invoke uploadSkin on account types that override it with a real implementation","For implementers: override canUploadSkin() and uploadSkin() in your Account subclass to support skin upload"],"exampleFix":"// before\naccount.uploadSkin(true, skinFile);\n// after\nif (account.canUploadSkin()) {\n    account.uploadSkin(true, skinFile);\n}","handlingStrategy":"type-guard","validationCode":"if (!account.canUploadSkin()) {\n    return; // feature unsupported for this account type\n}","typeGuard":"boolean canUpload = account.canUploadSkin();","tryCatchPattern":"try {\n    account.uploadSkin(isSlim, skinFile);\n} catch (UnsupportedOperationException e) {\n    ui.showInfo(\"Skin upload is not supported for this account type\");\n}","preventionTips":["Gate skin-upload UI on canUploadSkin()","Only call uploadSkin on supported account implementations","Handle new Account subclasses explicitly when adding features"],"tags":["minecraft","accounts","skins","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"24702dc5a0214034f4c27166d5fd30cad08cec19","analyzedAt":"2026-09-10T12:36:46.680Z","contentChangedAt":"2026-09-10T12:36:46.680Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}