{"record":{"id":"3775021663be99ad","repo":"bitwarden/server","slug":"you-cannot-import-this-much-data-at-once-the-limi","errorCode":null,"errorMessage":"You cannot import this much data at once, the limit is 1000 projects and 6000 secrets.","messagePattern":"You cannot import this much data at once, the limit is 1000 projects and 6000 secrets\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Api/SecretsManager/Controllers/SecretsManagerPortingController.cs","lineNumber":70,"sourceCode":"        if (projects == null && secrets == null)\n        {\n            throw new NotFoundException();\n        }\n\n        return new SMExportResponseModel(projects.Select(p => p.Project), secrets.Select(s => s.Secret));\n    }\n\n    [HttpPost(\"sm/{organizationId}/import\")]\n    public async Task Import([FromRoute] Guid organizationId, [FromBody] SMImportRequestModel importRequest)\n    {\n        if (!await _currentContext.OrganizationAdmin(organizationId) || !_currentContext.AccessSecretsManager(organizationId))\n        {\n            throw new NotFoundException();\n        }\n\n        if (importRequest.Projects?.Count() > 1000 || importRequest.Secrets?.Count() > 6000)\n        {\n            throw new BadRequestException(\"You cannot import this much data at once, the limit is 1000 projects and 6000 secrets.\");\n        }\n\n        if (importRequest.Secrets.Any(s => s.ProjectIds.Count() > 1))\n        {\n            throw new BadRequestException(\"A secret can only be in one project at a time.\");\n        }\n\n        var projectsToAdd = importRequest.Projects?.Count();\n        if (projectsToAdd is > 0)\n        {\n            var (max, overMax) = await _maxProjectsQuery.GetByOrgIdAsync(organizationId, projectsToAdd.Value);\n            if (overMax != null && overMax.Value)\n            {\n                throw new BadRequestException($\"The maximum number of projects for this plan is ({max}).\");\n            }\n        }\n\n        await _importCommand.ImportAsync(organizationId, importRequest.ToSMImport());","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/SecretsManager/Controllers/SecretsManagerPortingController.cs#L52-L88","documentation":"Thrown at SecretsManagerPortingController.cs:70 inside Import. The payload's project count exceeds 1000 or the secret count exceeds 6000 (importRequest.Projects?.Count() > 1000 || importRequest.Secrets?.Count() > 6000). The controller throws BadRequestException with the message about the 1000-project / 6000-secret limit -> HTTP 400. These are hard per-request caps to bound import work.","triggerScenarios":"POST /sm/{org}/import with a body containing more than 1000 projects or more than 6000 secrets in a single request.","commonSituations":"Bulk-migrating a large vault from another secrets backend in one shot; CI import job reading an un-split JSON/CSV file; miscounted payload generation.","solutions":["Chunk the import into batches of at most 1000 projects and 6000 secrets per request.","Pre-count the parsed payload and split before sending.","Stream/ paginate the source file so each request stays under both limits."],"exampleFix":"// before: one giant import\nawait adminClient.PostAsync($\"/sm/{orgId}/import\", FullImport(allProjects, allSecrets)); // 400\n\n// after: paginate respecting both caps\nforeach (var batch in ImportBatches(allProjects, allSecrets, maxProjects: 1000, maxSecrets: 6000))\n    await adminClient.PostAsync($\"/sm/{orgId}/import\", batch);","handlingStrategy":"validation","validationCode":"const int MaxProjects = 1000, MaxSecrets = 6000;\nif (import.Projects?.Count() > MaxProjects || import.Secrets?.Count() > MaxSecrets)\n    throw new ArgumentException($\"Import exceeds {MaxProjects} projects / {MaxSecrets} secrets\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Chunk imports to stay under 1000 projects and 6000 secrets per request.","Count the parsed payload before sending.","Stream large source files in fixed-size batches."],"tags":["csharp","aspnet","bitwarden","secrets-manager","import","validation","limits","api"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}