bitwarden/server · error · BadRequestException

Invalid content.

Error message

Invalid content.

What it means

Error "Invalid content." thrown in bitwarden/server.

Source

Thrown at src/Api/Vault/Controllers/CiphersController.cs:1390

        await _cipherService.ValidateCipherEditForAttachmentAsync(cipher, userId, orgAdmin, attachment.Size);

        return new AttachmentUploadDataResponseModel
        {
            Url = await _attachmentStorageService.GetAttachmentUploadUrlAsync(cipher, attachment),
            FileUploadType = _attachmentStorageService.FileUploadType,
        };
    }

    [HttpPost("{id}/attachment/{attachmentId}")]
    [SelfHosted(SelfHostedOnly = true)]
    [RequestSizeLimit(Constants.FileSize501mb)]
    [DisableFormValueModelBinding]
    public async Task PostFileForExistingAttachment(Guid id, string attachmentId)
    {
        if (!Request?.ContentType.Contains("multipart/") ?? true)
        {
            throw new BadRequestException("Invalid content.");
        }

        var userId = _userService.GetProperUserId(User).Value;
        var cipher = await GetByIdAsync(id, userId);

        var orgAdmin = false;
        if (cipher.OrganizationId.HasValue &&
            await CanEditCipherAsAdminAsync(cipher.OrganizationId.Value, new[] { cipher.Id }))
        {
            orgAdmin = true;
        }
        var attachments = cipher?.GetAttachments();
        if (attachments == null || !attachments.TryGetValue(attachmentId, out var attachmentData))
        {
            throw new NotFoundException();
        }

        await Request.GetFileAsync(async (stream) =>

View on GitHub (pinned to e93b962371)

Solutions

  1. Verify the multipart form data includes all required fields and valid file content, then retry.
  2. Use the official Bitwarden client or API models to construct the attachment upload.
  3. Check that the content type and encoding of the attachment match the declared metadata.

When it happens

Trigger: Thrown in CiphersController when the request content is invalid, e.g., malformed multipart data or a body that cannot be parsed for the requested cipher operation.

Common situations: See trigger scenarios.


AI-assisted analysis of bitwarden/server@e93b962371 (2026-08-13). Data as JSON: /api/errors/d42b5bcdfa4b4d6d. Report an issue: GitHub.