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

Allow empty log lines to be sent from the worker #2915

Merged
merged 4 commits into from
Feb 11, 2025
Merged

Conversation

stuartc
Copy link
Member

@stuartc stuartc commented Feb 7, 2025

Refactor log message handling to allow nil values and improve error validation.

console.log();          => new line
console.log('');        => new line
console.log(null);      => null
console.log(undefined); => new line

Closes #2914

Description

We now allow the worker to send through empty log lines.

"Empty" in this case means 'something', the default value for the schema is now nil, and so "" is valid because thats the value from the worker.

We still reject some messages, if the worker doesn't send anything for a LogLine message, that's still invalid.

Validation steps

This is not 1:1 demonstrable in a dev environment, because the error in Sentry is a "soft-error". There is not exception as such but rather a "error" logged to Sentry.

We never really tested for blank lines because (well 😅) it ignored them.

Applying this diff to main:

diff --git a/test/integration/web_and_worker_test.exs b/test/integration/web_and_worker_test.exs
index 263d1c459..f3c843d2d 100644
--- a/test/integration/web_and_worker_test.exs
+++ b/test/integration/web_and_worker_test.exs
@@ -346,6 +353,10 @@ defmodule Lightning.WebAndWorkerTest do
 
   defp flow_expression do
     "fn(state => {
+      console.log();
+      console.log('');
+      console.log(null);
+      console.log(undefined);
       console.log(state.configuration);
       throw 'fail!'
     });"

And adding something like a raise "hell" to reply_with/2 at lib/lightning_web/channels/channel_helpers.ex:7 and then run mix test test/integration/web_and_worker_test.exs; will result in a test failure.

AI Usage

Please disclose how you've used AI in this work (it's cool, we just want to know!):

  • Code generation (copilot but not intellisense)
  • Learning or fact checking
  • Strategy / design
  • Optimisation / refactoring
  • Translation / spellchecking / doc gen
  • Other
  • I have not used AI

You can read more details in our Responsible AI Policy

Pre-submission checklist

  • I have performed a self-review of my code.
  • I have implemented and tested all related authorization policies. (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

…alidation

```
console.log();          => new line
console.log('');        => new line
console.log(null);      => null
console.log(undefined); => new line
```

Closes #2914
@stuartc stuartc self-assigned this Feb 7, 2025
Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.52%. Comparing base (70112a0) to head (4572671).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
lib/lightning/invocation/log_line.ex 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2915      +/-   ##
==========================================
+ Coverage   91.49%   91.52%   +0.02%     
==========================================
  Files         344      344              
  Lines       12509    12512       +3     
==========================================
+ Hits        11445    11451       +6     
+ Misses       1064     1061       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stuartc stuartc marked this pull request as ready for review February 11, 2025 08:55
@stuartc stuartc requested a review from midigofrank February 11, 2025 08:55
@stuartc stuartc merged commit 8ec97c0 into main Feb 11, 2025
7 of 8 checks passed
@stuartc stuartc deleted the accept_empty_log_lines branch February 11, 2025 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Allow for blank log lines
2 participants