-
Notifications
You must be signed in to change notification settings - Fork 56
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
Suppress Warnings from CombinePDF in CI #16705
Suppress Warnings from CombinePDF in CI #16705
Conversation
@@ -106,13 +106,20 @@ def stringify_address(address) | |||
def combine_pdf(id, page1_path, page2_path, page3_path, page4_path) | |||
output_path = "/tmp/#{id}_final.pdf" | |||
|
|||
# Temporarily suppress CombinePDF warning in CI | |||
# Couldn't connect reference for ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we determined the root cause here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds innocuous. Should we just ignore it everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, I'm not on y'all's team but I've also been researching the cause of these messages. This is the most pertinent conversation/documentation I've been able to find on the topic. From what they can tell, the cause is most likely different PDF authoring tools assigning NULL objects. The warnings happen in case this in unintentional.
Here is the exact line that appears to be setting the warning:
https://github.com/boazsegev/combine_pdf/blob/master/lib/combine_pdf/parser.rb#L664
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Root cause: there's NULL objects. The raw data may not contain some information such as an apartment number, so when it's transformed to "page data" there's nil values:
:"F[0].Page_1[0].Claimants_MailingAddress_ApartmentOrUnitNumber[1]"=>nil,
Also by temporarily I meant the suppression is limited to the #combine_pdf
method. Poor wording on my part.
@stevenjcumming Rather than manipulate the global variable, could we instead if ENV['CI'] == 'true'
CombinePDF::PDFParser.prepend(Module.new do
SUPPRESSIBLE_WARNING = "Couldn't connect reference for"
def warn(*msgs, **)
msgs.reject! { _1.start_with? SUPPRESSIBLE_WARNING }
super
end
end)
end Is this warning always suppressible no matter who uses this library, or only in the exact three places you patched? Thanks for addressing this! |
@nihil2501 I thought it might be better to keep this more visible since it's kind of random and I don't like surprise patches. But I'm open to other approaches especially if it's what your team prefers. My only goal was to reduce the logs in CI. I don't think the warning should always be suppressed because it could indicate an issue. But as long as the PDF itself is checked against a good copy I think it's okay to suppress in a test environment. I will update the PR with your approach. |
@stevenjcumming How about using refinements in just those files to apply the patch explicitly locally rather than unexplicitly globally? It'd be the first time I've ever used Ruby refinements personally. module CombinePDF
class PDFParser
module WithWarningSuppressed
MESSAGE = "Couldn't connect reference for"
if ENV['CI'] == 'true'
refine module_parent do
def warn(*messages, **)
messages.reject! { _1.start_with? MESSAGE }
super
end
end
end
end
end
end
parser = CombinePDF::PDFParser.new('')
parser.send(:warn, "Couldn't connect reference for", "hi")
# => Couldn't connect reference for
# => hi
using CombinePDF::PDFParser::WithWarningSuppressed
parser.send(:warn, "Couldn't connect reference for", "hi")
# => hi |
Error: A file (or its parent directories) does not have a CODEOWNERS entry. Please update the .github/CODEOWNERS file and add the entry for the Offending file: config/initializers/combine_pdf_log_patch.rb |
I think it's fine considering the potential impact is low. If someone wants to change it in the future that's fine with me. |
I think we should patch this everywhere, not just CI/test. A large cost in DD is superfluous logs. Is there a reason we should keep this in other places besides test? Perhaps we'd want it in dev but not test/prod (e.g. |
Summary
CombinePDF logs a warning "Couldn't connect reference for..." when NULL objects have empty values. NULL objects do not necessarily indicate that there is an error hence the warning. source
In order to reduce the log output in CI the warning is suppressed. Even if there is an error, the test itself will catch this.
Tasks
Related issue(s)
Testing done
modules/claims_api
and modules/simple_forms_api`What areas of the site does it impact?
modules/claims_api
modules/simple_forms_api
Acceptance Criteria