Repository navigation
Fix #1002: use org default LoggerSettings for anonymous logs - #1029
Open
RajPabnani03 wants to merge 1 commit into
Open
RajPabnani03 wants to merge 1 commit into
RajPabnani03 wants to merge 1 commit into
Conversation
When a Log__c record is created without a LoggedBy__c value (e.g., logs created from LogEntryEvent__e platform events by external systems), Logger.getUserSettings() skipped the org-level defaults because the LoggerSettings__c.getOrgDefaults() check required a non-null user ID. Anonymous logs then fell back to the field default values (e.g., LogRetentionDate__c default of 14 days) instead of the configured org-level LoggerSettings__c. The settings hierarchy is now consistently applied for anonymous contexts: User -> Profile -> Org -> Field Default.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1002 —
Log__crecords created withoutLoggedBy__c(e.g., logs created by external systems viaLogEntryEvent__eplatform events) skipped the org-levelLoggerSettings__cand fell back to the metadata field default forLogRetentionDate__c(14 days), causing anonymous logs to be purged earlier than the configured retention policy.In
Logger.getUserSettings(Schema.User loggingUser), the org-defaults step was gated onloggingUser.Id != null, so anonymous contexts degenerated to "field default only":Org defaults are org-wide and don't depend on a user ID, so the documented settings hierarchy — User → Profile → Org → Field Default — now applies consistently for anonymous logs as well. This also fixes the same gap in
LogEntryEventHandler(which routesLogEntryEvent__e.LoggedById__cthrough the same method). TheSetupOwnerIdreassignment stays guarded onloggingUser.Id != null, since it only applies when a real user context exists.Adds
it_should_use_org_default_settings_when_user_is_nulltoLogger_Tests, covering aSchema.Userwith noId/ProfileId.Testing
Verified in a scratch org (Enterprise Edition, API v67): full
nebula-logger/coredeploy succeeded and the complete local Apex suite passed — 1260/1260 tests, 93% org-wide coverage — including the newit_should_use_org_default_settings_when_user_is_null.