{"record":{"id":"808675ffb98c6198","repo":"bitwarden/server","slug":"invalid-lastknownrevisiondate-format","errorCode":null,"errorMessage":"Invalid lastKnownRevisionDate format.","messagePattern":"Invalid lastKnownRevisionDate format\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Api/Vault/Controllers/CiphersController.cs","lineNumber":1681,"sourceCode":"\n    private async Task<CipherOrganizationDetails> GetByIdAsyncAdmin(Guid cipherId)\n    {\n        return await _cipherRepository.GetOrganizationDetailsByIdAsync(cipherId);\n    }\n\n    private async Task<CipherDetails> GetByIdAsync(Guid cipherId, Guid userId)\n    {\n        return await _cipherRepository.GetByIdAsync(cipherId, userId);\n    }\n\n    private DateTime? GetLastKnownRevisionDateFromForm()\n    {\n        DateTime? lastKnownRevisionDate = null;\n        if (Request.Form.TryGetValue(\"lastKnownRevisionDate\", out var dateValue))\n        {\n            if (!DateTime.TryParse(dateValue, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out var parsedDate))\n            {\n                throw new BadRequestException(\"Invalid lastKnownRevisionDate format.\");\n            }\n            lastKnownRevisionDate = parsedDate;\n        }\n\n        return lastKnownRevisionDate;\n    }\n#nullable enable\n\n    private async Task<OrganizationAbility?> GetOrganizationAbilityAsync(CipherDetails cipher)\n    {\n        if (cipher.OrganizationId.HasValue)\n        {\n            return await _organizationAbilityCacheService.GetOrganizationAbilityAsync(cipher.OrganizationId.Value);\n        }\n        return null;\n    }\n\n    private static OrganizationAbility? GetOrganizationAbility(CipherDetails cipher, IDictionary<Guid, OrganizationAbility> organizationAbilities) =>","sourceCodeStart":1663,"sourceCodeEnd":1699,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/Vault/Controllers/CiphersController.cs#L1663-L1699","documentation":"Thrown by GetLastKnownRevisionDateFromForm when the 'lastKnownRevisionDate' form field is present but cannot be parsed by DateTime.TryParse with CultureInfo.InvariantCulture and DateTimeStyles.RoundtripKind. This field is used for optimistic concurrency — the server compares it against the cipher's actual revision date to detect stale edits. The expected format is ISO 8601 roundtrip (e.g., 2024-01-15T10:30:00.0000000Z).","triggerScenarios":"Sending a date in a locale-specific format (e.g., '15/01/2024' or 'Jan 15, 2024'); sending a Unix timestamp instead of a date string; sending a malformed or empty date value in the form field; the client serializes DateTime using its local culture instead of InvariantCulture.","commonSituations":"Client running under a non-invariant culture that formats dates differently; a form field populated with a default/placeholder value that isn't a valid date; client library that uses a different DateTime serialization format; testing tools that send raw timestamps.","solutions":["Send the date in ISO 8601 roundtrip format (the 'O' format specifier): e.g., 2024-01-15T10:30:00.0000000Z","On the client, format using DateTime.ToString(\"O\", CultureInfo.InvariantCulture)","Ensure the form field name is exactly 'lastKnownRevisionDate'","Omit the field entirely if you don't have a valid last-known revision date rather than sending an invalid value"],"exampleFix":"// before (locale-dependent format, may fail under non-US cultures)\nform[\"lastKnownRevisionDate\"] = lastSync.ToString();\n\n// after (ISO 8601 roundtrip, culture-invariant, RoundtripKind-compatible)\nform[\"lastKnownRevisionDate\"] = lastSync.ToString(\"O\", CultureInfo.InvariantCulture);","handlingStrategy":"validation","validationCode":"// Validate date format before sending\nif (!DateTime.TryParse(dateString, CultureInfo.InvariantCulture,\n    DateTimeStyles.RoundtripKind, out _))\n{\n    // Reformat using ISO 8601 roundtrip format\ndateString = lastKnownRevisionDate.ToString(\"O\", CultureInfo.InvariantCulture);\n}\nform[\"lastKnownRevisionDate\"] = dateString;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always format dates using the 'O' (roundtrip) format specifier with InvariantCulture","Omit the lastKnownRevisionDate field entirely if you don't have a valid value","Ensure the form field name is exactly 'lastKnownRevisionDate'","Never send locale-formatted date strings — always use ISO 8601"],"tags":["date-format","validation","form-data","revision-date","i18n","concurrency"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}