{"record":{"id":"d584d343fc031e17","repo":"beemdevelopment/Aegis","slug":"period-is-not-an-integer","errorCode":null,"errorMessage":"Period is not an integer.","messagePattern":"Period is not an integer\\.","errorType":"validation","errorClass":"ParseException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/com/beemdevelopment/aegis/ui/EditEntryActivity.java","lineNumber":713,"sourceCode":"        saveAndFinish(entry, true);\n    }\n\n    private void saveAndFinish(VaultEntry entry, boolean delete) {\n        Intent intent = new Intent();\n        intent.putExtra(\"entryUUID\", entry.getUUID());\n        intent.putExtra(\"delete\", delete);\n\n        if (saveAndBackupVault()) {\n            setResult(RESULT_OK, intent);\n            finish();\n        }\n    }\n\n    private int parsePeriod() throws ParseException {\n        try {\n            return Integer.parseInt(_textPeriodCounter.getText().toString());\n        } catch (NumberFormatException e) {\n            throw new ParseException(\"Period is not an integer.\");\n        }\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)) {","sourceCodeStart":695,"sourceCodeEnd":731,"githubUrl":"https://github.com/beemdevelopment/Aegis/blob/d6f4e5925a97e4e91593f1542085eae03432a759/app/src/main/java/com/beemdevelopment/aegis/ui/EditEntryActivity.java#L695-L731","documentation":"EditEntryActivity.parsePeriod() parses the period/counter field of an OTP entry with Integer.parseInt and wraps any NumberFormatException in a ParseException. Aegis throws this when the user saves an entry whose HOTP counter or custom period field is empty or contains non-numeric text, since a non-integer period cannot be used to construct a valid TotpInfo/HotpInfo.","triggerScenarios":"Saving an edited TOTP/HOTP entry while the 'Period' (counter) text field is empty, contains letters, spaces, decimal points, or other non-integer characters; Integer.parseInt throws NumberFormatException which is rethrown as ParseException.","commonSituations":"Users accidentally typing characters into the period/counter field, clearing the field before saving, or pasting formatted values like '30s' or '30.0' into the field when editing advanced OTP settings.","solutions":["Enter a plain integer value (e.g. 30 for TOTP period or a valid HOTP counter) in the period/counter field before saving","Clear the field and retype the value to remove invisible characters or stray whitespace","Restore the entry's original period/counter value if you did not intend to change it"],"exampleFix":"// before\ncounterField.setText(\"30s\");\n// after\ncounterField.setText(\"30\");","handlingStrategy":"validation","validationCode":"String period = textPeriodCounter.getText().toString().trim();\nif (!period.matches(\"\\\\d+\")) {\n    // show input error before calling save\n}","typeGuard":null,"tryCatchPattern":"try {\n    saveEntry();\n} catch (ParseException e) {\n    if (\"Period is not an integer.\".equals(e.getMessage())) {\n        _textPeriodCounterLayout.setError(\"Enter a whole number\");\n    }\n}","preventionTips":["Validate the period/counter field with a numeric TextWatcher before enabling save","Trim and sanitize pasted values into the field","Use a numeric input type (inputType=\"number\") for the field"],"tags":["android","validation","otp","input-parsing"],"backgroundTag":"invalid-argument-format","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"}