{"record":{"id":"cde71014d5cd8407","repo":"MuntashirAkon/AppManager","slug":"invalid-ssaid-length","errorCode":null,"errorMessage":"Invalid SSAID ${length}","messagePattern":"Invalid SSAID (.+?)","errorType":"validation","errorClass":"java.io.IOException","httpStatus":null,"severity":"warning","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/ssaid/ChangeSsaidDialog.java","lineNumber":104,"sourceCode":"        AtomicReference<Button> resetButton = new AtomicReference<>();\n\n        alertDialog.setOnShowListener(dialog -> {\n            applyButton.set(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));\n            resetButton.set(alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));\n            applyButton.get().setVisibility(View.GONE);\n            applyButton.get().setOnClickListener(v -> {\n                mSsaidChangedResult = ThreadUtils.postOnBackgroundThread(() -> {\n                    try {\n                        Editable editable = ssaidEditText.getText();\n                        if (editable == null) {\n                            throw new IOException(\"Empty SSAID field.\");\n                        }\n                        mSsaid = editable.toString();\n                        if (mSsaid.length() != sizeByte * 2) {\n                            throw new IOException(\"Invalid SSAID size \" + mSsaid.length());\n                        }\n                        if (!mSsaid.matches(\"[0-9A-Fa-f]+\")) {\n                            throw new IOException(\"Invalid SSAID \" + mSsaid.length());\n                        }\n                        SsaidSettings ssaidSettings = new SsaidSettings(UserHandleHidden.getUserId(uid));\n                        boolean isSuccess = ssaidSettings.setSsaid(packageName, uid, mSsaid);\n                        if (isSuccess) {\n                            alertDialog.dismiss();\n                        }\n                        if (mSsaidChangedInterface != null) {\n                            ThreadUtils.postOnMainThread(() -> mSsaidChangedInterface.onSsaidChanged(mSsaid, isSuccess));\n                        }\n                    } catch (IOException e) {\n                        e.printStackTrace();\n                        if (mSsaidChangedInterface != null) {\n                            ThreadUtils.postOnMainThread(() -> mSsaidChangedInterface.onSsaidChanged(mSsaid, false));\n                        }\n                    }\n                });\n            });\n            resetButton.get().setVisibility(View.GONE);","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/ssaid/ChangeSsaidDialog.java#L86-L122","documentation":"IOException thrown when the SSAID passes the length check but contains characters outside [0-9A-Fa-f], i.e. it is not a valid hexadecimal string. SSAIDs must be pure hex, so the dialog rejects the value before calling SsaidSettings.setSsaid.","triggerScenarios":"Entering a SSAID containing letters outside A-F (e.g. G-Z), digits with '0x' prefix, spaces, hyphens, or other punctuation; mSsaid.matches(\"[0-9A-Fa-f]+\") fails and the error is thrown with the invalid length as detail.","commonSituations":"Pasting a UUID with hyphens; copying an identifier with surrounding text; user typing 'O' instead of '0' or including a '0x' prefix from a debugger view.","solutions":["Strip non-hex characters (hyphens, spaces, 0x prefix) from the input before validation","Use an InputFilter/KeyListener restricting the EditText to hex characters","Normalize the input to uppercase and trim before the regex check","Catch the IOException and show a 'value must be hexadecimal' message"],"exampleFix":"// before\nif (!mSsaid.matches(\"[0-9A-Fa-f]+\")) {\n    throw new IOException(\"Invalid SSAID \" + mSsaid.length());\n}\n// after\nmSsaid = mSsaid.replaceFirst(\"^0x\", \"\").replaceAll(\"[-\\\\s]\", \"\").toUpperCase(Locale.US);\nif (!mSsaid.matches(\"[0-9A-F]+\")) {\n    ssaidEditText.setError(getContext().getString(R.string.ssaid_must_be_hex));\n    return null;\n}","handlingStrategy":"validation","validationCode":"String text = ssaidEditText.getText().toString().trim().replaceFirst(\"^0x\", \"\").replaceAll(\"[-\\\\s]\", \"\");\nif (!text.matches(\"[0-9A-Fa-f]+\")) {\n    ssaidEditText.setError(\"SSAID must be hexadecimal\");\n    return;\n}","typeGuard":"boolean isHex(String s) { return s != null && !s.isEmpty() && s.chars().allMatch(c -> Character.digit(c, 16) >= 0); }","tryCatchPattern":"try {\n    applySsaid();\n} catch (IOException e) {\n    ssaidEditText.setError(context.getString(R.string.ssaid_must_be_hex));\n}","preventionTips":["Restrict EditText input to hex characters via InputFilter","Sanitize pasted UUIDs (strip hyphens/0x) automatically","Normalize to a single case before validation","Show a live validation indicator as the user types"],"tags":["android","validation","ssaid","hex"],"backgroundTag":"invalid-identifier-format","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}