{"record":{"id":"d50fee029c4f9833","repo":"beemdevelopment/Aegis","slug":"pin-must-have-a-length-of-4-digits","errorCode":null,"errorMessage":"PIN must have a length of 4 digits.","messagePattern":"PIN must have a length of 4 digits\\.","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/beemdevelopment/aegis/ui/EditEntryActivity.java","lineNumber":732,"sourceCode":"        }\n    }\n\n    private VaultEntry parseEntry() throws ParseException {\n        if (_textSecret.length() == 0) {\n            throw new ParseException(\"Secret is a required field.\");\n        }\n\n        String type = _dropdownType.getText().toString();\n        String algo = _dropdownAlgo.getText().toString();\n        String lowerCasedType = type.toLowerCase(Locale.ROOT);\n\n        if (lowerCasedType.equals(YandexInfo.ID) || lowerCasedType.equals(MotpInfo.ID)) {\n            int pinLength = _textPin.length();\n            if (pinLength < 4) {\n                throw new ParseException(\"PIN is a required field. Must have a minimum length of 4 digits.\");\n            }\n            if (pinLength != 4 && lowerCasedType.equals(MotpInfo.ID)) {\n                throw new ParseException(\"PIN must have a length of 4 digits.\");\n            }\n        }\n\n        int digits;\n        try {\n            digits = Integer.parseInt(_textDigits.getText().toString());\n        } catch (NumberFormatException e) {\n            throw new ParseException(\"Digits is not an integer.\");\n        }\n\n        byte[] secret;\n        try {\n            String secretString = new String(EditTextHelper.getEditTextChars(_textSecret));\n\n            secret = (lowerCasedType.equals(MotpInfo.ID)) ?\n                    Hex.decode(secretString) : GoogleAuthInfo.parseSecret(secretString);\n\n            if (secret.length == 0) {","sourceCodeStart":714,"sourceCodeEnd":750,"githubUrl":"https://github.com/beemdevelopment/Aegis/blob/d6f4e5925a97e4e91593f1542085eae03432a759/app/src/main/java/com/beemdevelopment/aegis/ui/EditEntryActivity.java#L714-L750","documentation":"For MOTP-type entries, EditEntryActivity.parseEntry() additionally requires the PIN to be exactly 4 digits (Yandex accepts 4+). This ParseException is thrown when the PIN is 4 or more characters but not exactly 4, since the MOTP algorithm consumes a fixed 4-digit PIN.","triggerScenarios":"Saving an entry with type MotpInfo.ID while _textPin length is 5 or more (e.g. '12345'); the earlier min-length check passed but the exactly-4 check fails.","commonSituations":"Users entering a longer passcode for a MOTP entry, or pasting a PIN plus extra digits, not realizing MOTP mandates exactly 4 digits.","solutions":["Enter exactly 4 digits in the PIN field for MOTP entries","Trim any extra characters from the PIN before saving","Switch the entry type to Yandex if you need a longer PIN"],"exampleFix":"// before\npinField.setText(\"12345\"); // MOTP\n// after\npinField.setText(\"1234\"); // MOTP","handlingStrategy":"validation","validationCode":"if (type.equals(\"motp\") && _textPin.length() != 4) {\n    _textPinLayout.setError(\"MOTP PIN must be exactly 4 digits\");\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    saveEntry();\n} catch (ParseException e) {\n    if (\"PIN must have a length of 4 digits.\".equals(e.getMessage())) {\n        _textPinLayout.setError(\"MOTP PIN must be exactly 4 digits\");\n    }\n}","preventionTips":["For MOTP entries, set maxLength=4 on the PIN field","Document the exactly-4-digit MOTP PIN requirement in the UI hint","Differentiate Yandex (4+) and MOTP (exactly 4) validation per type"],"tags":["android","validation","otp","motp","pin-length"],"backgroundTag":"invalid-argument-value","analyzedSha":"d6f4e5925a97e4e91593f1542085eae03432a759","analyzedAt":"2026-09-08T00:46:31.111Z","contentChangedAt":"2026-09-08T00:46:31.111Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}