Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log but no entries #199

Closed
vr8hub opened this issue Sep 10, 2021 · 11 comments · Fixed by #188
Closed

Log but no entries #199

vr8hub opened this issue Sep 10, 2021 · 11 comments · Fixed by #188
Labels
Layer: Log Management Items related to the custom objects & Logger Console app Logging Source: Flow Items related to using Nebula Logger within Flow Type: Bug Something isn't working

Comments

@vr8hub
Copy link

vr8hub commented Sep 10, 2021

Sorry, apparently I'm this week's problem child.

I have two "Add Log Entry for SObject Record Collection" actions in a flow, and only those actions. Both have Save Log set to True, both with Logging Level set to DEBUG. Both are in the path that will get called. (Confirmed with debug before I put the logging in.)

The Flow completes successfully. However, the Logger console shows me only a Log__c entry, no Log Entries. After the first time it happened, I deleted the log (so no logs at all) and ran the flow again, same result. Since I'm only calling actions that should create a log entry, I don't know how that could be happening; if the log actions weren't getting hit at all, there wouldn't be a log record, but since there's a log record, that implies that they are getting hit, but there's no log entry records, which the actions should both be creating.

I have the Logger: Admin permission set assigned to my user. (I'm a sysadmin.) I also created a Logger Setting entry for my user (and only that one, no org default), with Logging Level set to DEBUG and Is Enabled checked, everything else defaulted (Read, 14, EVENT_BUS, etc.). With my level set to DEBUG and the flow actions set to DEBUG, my understanding is that they should be created.

What am I missing and/or doing wrong?

@vr8hub
Copy link
Author

vr8hub commented Sep 10, 2021

I turned off the logging level on the two actions so that it used the default (which is?), but it didn't make any difference. Still only a log created, no log entries.

@jongpie
Copy link
Owner

jongpie commented Sep 10, 2021

Hey @vr8hub - it sounds like you're doing everything correctly, so it could be a bug of some sort. I've seen similar issues happen before where the Log__c record is created, but the LogEntry__c records fail - these failures happen asynchronously, so you typically won't see the errors when the Flow runs.

One option you can try is updating your Logger Setting entry to use SYNCHRONOUS_DML as the default save method (instead of EVENT_BUS), and then try running your Flow again - that will (hopefully) show you whatever error is happening that's preventing the LogEntry__c records from saving. If that works, let me know what the error is and I can help from there.

@vr8hub
Copy link
Author

vr8hub commented Sep 10, 2021

I made the change, but no difference—I still got just a Log record with no LogEntries, and no error. I checked and the SysAdmin profile has full privileges on both objects (Log and LogEntry). I also added a plain "Add Log Entry" to see if it was isolated to the record collection action; it's not, i.e. I still didn't get any log entries even after that (total of three actions, one Add Log, two Add Log Record Collection).

@vr8hub
Copy link
Author

vr8hub commented Sep 10, 2021

So sorry, spoke too soon. I didn't notice—something (SF?) created an org default for the Logger settings, and it was that I changed to sync, not my user settings. So I deleted my user settings since SF apparently doesn't like a user having settings when there isn't an org default. I ran it again, and this time got an error:
Error Occurred: An Apex error occurred: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LogEntry: data changed by trigger for field Flow Description: data value too large: (value has been hidden): []

@jamessimone
Copy link
Collaborator

jamessimone commented Sep 10, 2021

@vr8hub we can arrive at a more elegant solution for this, but in the meantime, if you navigate to the LogEntryEventHandler class, if you update line 215 from:

insert this.logEntries;

to:

Database.DMLOptions dmlOptions = new Database.DMLOptions();
dmlOptions.AllowFieldTruncation = true;
Database.insert(this.logEntries, dmlOptions);

That will get you back on track for now.

@vr8hub
Copy link
Author

vr8hub commented Sep 10, 2021

So the LogEntryHandler class assigns the FlowDescription in LogEntry to the description from FlowDefinitionView, and in running that query manually, this particular flow's description (and several others of ours) have a description that's longer than 255 characters. So I'm guessing that assignment is what's blowing up.

@vr8hub
Copy link
Author

vr8hub commented Sep 10, 2021

Ahh, very good James, I posted before I saw your message. I'll make that change, thanks for your help!

@jamessimone
Copy link
Collaborator

jamessimone commented Sep 10, 2021

no problem, happy to help. Truncated field values are something we've looked at in other areas of logger, but in thinking about it, it makes sense that the Flow description could exceed 255 characters - we'll probably need to do an audit for other areas where this error might present itself! 😅

@vr8hub
Copy link
Author

vr8hub commented Sep 10, 2021

Before I make that change… is that going to work? If the assignment is what's causing the problem, isn't the insert too late to catch it? IOW, isn't it dying when the assignment is made, rather than when the insert happens?

@vr8hub
Copy link
Author

vr8hub commented Sep 10, 2021

I just added .left(255) to the end of the assignment in LogEntryHandler, and that got rid of the error, and lo and behold I have Log Entries. Yea!

Thank you both for all your help, and sorry for all the trouble!

@jongpie
Copy link
Owner

jongpie commented Sep 10, 2021

@vr8hub no trouble at all, thanks so much for all of the feedback! I'll include a fix for this issue when I also fix #198.

Let us know if you run into any other problems!

@jongpie jongpie added Type: Bug Something isn't working Logging Source: Flow Items related to using Nebula Logger within Flow Layer: Log Management Items related to the custom objects & Logger Console app labels Sep 10, 2021
jongpie added a commit that referenced this issue Sep 10, 2021
…field-truncation for LogEntry__c inserts (reported in #199)
jongpie added a commit that referenced this issue Sep 13, 2021
…field-truncation for LogEntry__c inserts (reported in #199)
jongpie added a commit that referenced this issue Sep 13, 2021
* Made record & records parameters optional in FlowRecordLogEntry & FlowCollectionLogEntry (respectively) to handle situations where null is passed (e.g., Get Records returns null for no matches, instead of an empty list) (reported in #198)

* Changed FlowDescription__c.field to long text area + added automatic field-truncation for LogEntry__c inserts + added a ridiculously long description to one of the Flows in nebula-logger-recipes (reported in #199)

* Made fancier buttons that include the release number

* Cleaned up a few areas in README

* Added 'Code Quality Tests' to deploy.yml + ran prettier

* Setup ESLint for lwc + fixed some reported issues

* Removed some unused scripts in package.json
jongpie added a commit that referenced this issue Sep 14, 2021
* Added StripInaccessibleRecordFields__c setting

* Added all CMDT objects to LoggerAdmin.permissionset

* Added LogEntryDataMaskRule__mdt object for applying data mask rules to log entry message & record JSON fields in LogEntryEventBuilder

* Added CMDT rules for credit card numbers & social security numbers

* Added setting ApplyDataMaskRules__c to control if CMDT data mask rules are applied

* Added some user managament settings to scratch-def files

* Added test suites for each module

* Moved some test helper methods to LoggerTestUtils, cleaned up LogEntryEventBuilder_Tests methods

* Optimized setTagsDetails()

* Made record & records parameters optional in FlowRecordLogEntry & FlowCollectionLogEntry (respectively) to handle situations where null is passed (e.g., Get Records returns null for no matches, instead of an empty list) (reported in #198)

* Changed FlowDescription__c.field to long text area + added automatic field-truncation for LogEntry__c inserts + added a ridiculously long description to one of the Flows in nebula-logger-recipes (reported in #199)

* Made fancier buttons that include the release number

* Cleaned up a few areas in README

* Added 'Code Quality Tests' to deploy.yml + ran prettier

* Setup ESLint for lwc + fixed some reported issues

* Removed some unused scripts in package.json

* Switched back to using extra-tests folder, created LogEntryEventBuilder_IntegrationTests class (AccountBrand doesn't exist in all orgs)

* Added new step to pipeline to create an unvalidated package version & auto-install it into the package-demo org, then reinstall the latest released package version

* Reenabled Codecov.io integration in the pipeline

* Added static code analysis / PMD through sfdx-scanner (#201 by @jamessimone)

* Fixed line breaks not working when calling System.debug()
@jamessimone and I had a lot of... "fun" with this one

Co-authored-by: James Simone <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: Log Management Items related to the custom objects & Logger Console app Logging Source: Flow Items related to using Nebula Logger within Flow Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants