{"record":{"id":"8fa9dec9e965515d","repo":"kgrzybek/modular-monolith-with-ddd","slug":"meeting-commenting-configuration-for-enabling-comm","errorCode":null,"errorMessage":"Meeting commenting configuration for enabling commenting must exist.","messagePattern":"Meeting commenting configuration for enabling commenting must exist\\.","errorType":"validation","errorClass":"InvalidCommandException","httpStatus":400,"severity":"error","filePath":"src/Modules/Meetings/Application/MeetingCommentingConfigurations/EnableMeetingCommentingConfiguration/EnableMeetingCommentingConfigurationCommandHandler.cs","lineNumber":34,"sourceCode":"\r\n        public EnableMeetingCommentingConfigurationCommandHandler(\r\n            IMeetingCommentingConfigurationRepository meetingCommentingConfigurationRepository,\r\n            IMeetingRepository meetingRepository,\r\n            IMeetingGroupRepository meetingGroupRepository,\r\n            IMemberContext memberContext)\r\n        {\r\n            _meetingCommentingConfigurationRepository = meetingCommentingConfigurationRepository;\r\n            _meetingRepository = meetingRepository;\r\n            _meetingGroupRepository = meetingGroupRepository;\r\n            _memberContext = memberContext;\r\n        }\r\n\r\n        public async Task Handle(EnableMeetingCommentingConfigurationCommand command, CancellationToken cancellationToken)\r\n        {\r\n            var meetingCommentingConfiguration = await _meetingCommentingConfigurationRepository.GetByMeetingIdAsync(new MeetingId(command.MeetingId));\r\n            if (meetingCommentingConfiguration == null)\r\n            {\r\n                throw new InvalidCommandException([\"Meeting commenting configuration for enabling commenting must exist.\"]);\r\n            }\r\n\r\n            var meeting = await _meetingRepository.GetByIdAsync(new MeetingId(command.MeetingId));\r\n\r\n            var meetingGroup = await _meetingGroupRepository.GetByIdAsync(meeting.GetMeetingGroupId());\r\n\r\n            meetingCommentingConfiguration.EnableCommenting(_memberContext.MemberId, meetingGroup);\r\n        }\r\n    }\r\n}","sourceCodeStart":16,"sourceCodeEnd":44,"githubUrl":"https://github.com/kgrzybek/modular-monolith-with-ddd/blob/91c8ef24b4cb6ef558c95d8267fa07d68c7059f8/src/Modules/Meetings/Application/MeetingCommentingConfigurations/EnableMeetingCommentingConfiguration/EnableMeetingCommentingConfigurationCommandHandler.cs#L16-L44","documentation":"Thrown by EnableMeetingCommentingConfigurationCommandHandler when GetByMeetingIdAsync returns null. The handler needs an existing MeetingCommentingConfiguration to call EnableCommenting on; without one there is nothing to enable, so it rejects the command with InvalidCommandException (HTTP 400).","triggerScenarios":"Dispatching EnableMeetingCommentingConfigurationCommand with a MeetingId that has no configuration aggregate: empty Guid, non-existent meeting, deleted configuration, or enable called before the meeting's configuration was created.","commonSituations":"Re-enabling comments on a meeting that was archived/deleted; test fixtures that build a meeting without its configuration; UI state out of sync with the database after a failed creation.","solutions":["Verify the MeetingId exists and its commenting configuration row is present.","Re-create the meeting/configuration if it is legitimately missing instead of enabling.","Pre-check existence in the controller and return 404 before sending the command.","Map InvalidCommandException to a 400/404 response at the API boundary."],"exampleFix":"// before\nawait _commandDispatcher.SendAsync(new EnableMeetingCommentingConfigurationCommand(meetingId));\n\n// after\nvar exists = await _meetingQueries.ConfigurationExistsForMeetingAsync(meetingId);\nif (!exists) return NotFound(\"Commenting configuration not found for meeting.\");\nawait _commandDispatcher.SendAsync(new EnableMeetingCommentingConfigurationCommand(meetingId));","handlingStrategy":"validation","validationCode":"var exists = await _meetingQueries.ConfigurationExistsForMeetingAsync(meetingId);\nif (!exists) return NotFound(\"Commenting configuration not found for meeting.\");\nawait _commandDispatcher.SendAsync(new EnableMeetingCommentingConfigurationCommand(meetingId));","typeGuard":"public static bool IsValidMeetingId(EnableMeetingCommentingConfigurationCommand c) =>\n    c.MeetingId != Guid.Empty;","tryCatchPattern":"try { await _commandDispatcher.SendAsync(cmd); }\ncatch (InvalidCommandException ex) when (ex.Errors.Any(m => m.Contains(\"must exist\")))\n{ return NotFound(new { errors = ex.Errors }); }","preventionTips":["Only show 'enable comments' when the meeting/configuration is loaded and present.","Ensure tests seed the configuration before exercising enable/disable.","Reject empty Guids at the controller."],"tags":["meetings","commenting-configuration","not-found","invalid-command-exception","command-handler"],"backgroundTag":null,"analyzedSha":"91c8ef24b4cb6ef558c95d8267fa07d68c7059f8","analyzedAt":"2026-08-13T17:18:16.571Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}