{"record":{"id":"cab56b091a67d653","repo":"bitwarden/server","slug":"name-is-required","errorCode":null,"errorMessage":"Name is required.","messagePattern":"Name is required\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"bitwarden_license/src/Services/Pam/Services/AccessRuleWriteValidator.cs","lineNumber":34,"sourceCode":"    private readonly ICollectionRepository _collectionRepository;\n    private readonly IAccessRuleValidator _conditionsValidator;\n\n    public AccessRuleWriteValidator(\n        IAccessRuleRepository repository,\n        ICollectionRepository collectionRepository,\n        IAccessRuleValidator conditionsValidator)\n    {\n        _repository = repository;\n        _collectionRepository = collectionRepository;\n        _conditionsValidator = conditionsValidator;\n    }\n\n    public async Task<List<Guid>> ValidateAsync(Guid organizationId, AccessRule rule,\n        IEnumerable<Guid> collectionIds, Guid? existingRuleId = null)\n    {\n        if (string.IsNullOrWhiteSpace(rule.Name))\n        {\n            throw new BadRequestException(\"Name is required.\");\n        }\n\n        if (rule.AllowsExtensions && rule.MaxExtensionDurationSeconds is not > 0)\n        {\n            throw new BadRequestException(\"A maximum extension length is required when extensions are allowed.\");\n        }\n\n        var conditions = _conditionsValidator.Validate(rule.Conditions);\n        if (!conditions.IsValid)\n        {\n            throw new BadRequestException(conditions.Error!);\n        }\n\n        await ValidateNameIsUniqueAsync(organizationId, rule.Name, existingRuleId);\n\n        return await ValidateCollectionsAsync(organizationId, collectionIds, existingRuleId);\n    }\n","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/bitwarden_license/src/Services/Pam/Services/AccessRuleWriteValidator.cs#L16-L52","documentation":"Thrown as a BadRequestException (HTTP 400) by AccessRuleWriteValidator.ValidateAsync when the AccessRule.Name is null, empty, or whitespace. Name is a mandatory field for all PAM access rules — it is the human-readable identifier shown in the admin UI and used in name-uniqueness checks.","triggerScenarios":"Creating or updating a PAM AccessRule (POST or PUT to the access-rules endpoint) with a body where 'name' is omitted, null, empty, or only whitespace. Caused by a client omitting the field or sending an empty string.","commonSituations":"API client sends a partial update that omits name on a PUT (full replace) path. A UI form allows submission with an empty name field. Automated rule creation script has a null or empty name variable.","solutions":["Provide a non-empty, non-whitespace 'name' in the request body.","Add client-side validation to require name before submission.","If using PUT for a partial update, switch to PATCH or include the existing name."],"exampleFix":"// before\n//   { \"conditions\": {...}, \"collectionIds\": [...] }  // name missing\n// after\n//   { \"name\": \"Engineering Access Rule\", \"conditions\": {...}, \"collectionIds\": [...] }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(rule.Name))\n    throw new InvalidOperationException(\"AccessRule name is required\");\n// only then submit to API","typeGuard":null,"tryCatchPattern":"try { await pamClient.CreateAccessRuleAsync(orgId, rule); }\ncatch (HttpRequestException ex) when (ex.Message.Contains(\"Name is required\"))\n{ /* ensure name is provided and retry */ }","preventionTips":["Require a non-empty name in the UI form before enabling submit.","Validate rule.Name client-side before all create/update API calls.","For PUT (full replace) paths, always include the existing name."],"tags":["pam","validation","access-rules","http-400","required-field"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}