Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ features:
accredited_representative_portal_skip_itf_check:
actor_type: user
description: If enabled, skip existing ITF check in ARP
acroform_debug_logs:
actor_type: user
description: When enabled, AcroForm problematic fields will report in Rails logs
aedp_vadx:
actor_type: user
description: Enables the VADX experimental features in the AEDP application
Expand Down
3 changes: 2 additions & 1 deletion lib/pdf_fill/filler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,14 @@ def fill_ancillary_form(form_data, claim_id, form_id, fill_options = {})
#
# @return [None]
#

def fill_form_with_hexapdf(template_path, output_path, hash_data)
Rails.logger.info("PdfFill::Filler HexaPDF template: #{template_path}") if Flipper.enabled?(:acroform_debug_logs)
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logging behavior when the acroform_debug_logs feature flag is enabled lacks test coverage. The existing tests for fill_form_with_hexapdf don't verify this logging behavior. Add tests that verify the logging occurs when the flag is enabled and doesn't occur when disabled, following the pattern established in the codebase for feature flag testing.

Copilot uses AI. Check for mistakes.
doc = HexaPDF::Document.open(template_path)
form = doc.acro_form
raise 'No AcroForm found in PDF template.' if form.nil?

form.fill(hash_data)

doc.write(output_path)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def build_form_data(data)
end

def fill_and_write_pdf(form_data, output_path, email_delivery_failure)
if Flipper.enabled?(:acroform_debug_logs)
Rails.logger.info("DecisionReviews::PdfTemplateStamper #{@template_path}")
end
Comment on lines +67 to +69
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logging behavior when the acroform_debug_logs feature flag is enabled lacks test coverage. The existing tests for PdfTemplateStamper don't verify this logging behavior. Add tests that verify the logging occurs when the flag is enabled and doesn't occur when disabled, following the pattern established in the codebase for feature flag testing.

Copilot uses AI. Check for mistakes.

doc = HexaPDF::Document.open(@template_path)

fill_form_fields(doc, form_data, email_delivery_failure)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ def self.stamp_signature(pdf_path, form_data)
# @param pdf_path [String] Path to the PDF template
# @return [Hash, nil] Coordinates hash of the form
# `{ x: Float, y: Float, page_number: Integer }` or nil on failure
def self.signature_overlay_coordinates(pdf_path = TEMPLATE)
def self.signature_overlay_coordinates(pdf_path = TEMPLATE) # rubocop:disable Metrics/MethodLength
if Flipper.enabled?(:acroform_debug_logs)
Rails.logger.info("IncreaseCompensation::PdfStamper HexaPDF template: #{pdf_path}")
end
Comment on lines +47 to +49
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logging behavior when the acroform_debug_logs feature flag is enabled lacks test coverage. The minimal existing tests for PdfStamper don't exercise the signature_overlay_coordinates method. Add tests that verify the logging behavior both when the flag is enabled and disabled, following the pattern established in the codebase for feature flag testing.

Copilot uses AI. Check for mistakes.
doc = HexaPDF::Document.open(pdf_path)
return unless doc.validate(auto_correct: false)

Expand Down Expand Up @@ -71,7 +74,7 @@ def self.signature_overlay_coordinates(pdf_path = TEMPLATE)
end

def self.signature_text_for(form_data)
form_data['statementOfTruthSignature'].presence ||
form_data['statement_of_truth_signature'].presence ||
Comment thread
RachalCassity marked this conversation as resolved.
Outdated
form_data['signature'].presence ||
veteran_full_name(form_data)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,30 @@ def merge_fields(_options = {})
# @param pdf_path [String] Path to the PDF template
# @return [Hash, nil] Coordinates hash of the form
# `{ x: Float, y: Float, page_number: Integer }` or nil on failure
def self.signature_overlay_coordinates(pdf_path)
def self.signature_overlay_coordinates(pdf_path) # rubocop:disable Metrics/MethodLength
if Flipper.enabled?(:acroform_debug_logs)
Rails.logger.info("MedicalExpenseReports::PdfFill::Va21p8416 HexaPDF template: #{pdf_path}")
end

doc = HexaPDF::Document.open(pdf_path)
field = doc.acro_form&.field_by_name(SIGNATURE_FIELD_NAME)
form = doc.acro_form
raise 'No AcroForm found in PDF template.' if form.nil?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we could put this inside the flipper since it is changing behavior?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me revert that change


if Flipper.enabled?(:acroform_debug_logs)
# Find problematic fields
problematic_fields = form.each_field.select do |field|
field.field_type == :Btn && field[:AP].nil?
end

if problematic_fields.any?
Rails.logger.warn("Template #{template_path} has #{problematic_fields.size} fields missing AP")
Comment thread
RachalCassity marked this conversation as resolved.
Outdated
problematic_fields.each do |field|
Rails.logger.warn(" - Field: #{field.full_field_name}")
end
end
end
Comment thread
RachalCassity marked this conversation as resolved.
Outdated

field = form&.field_by_name(SIGNATURE_FIELD_NAME)
widget = field&.each_widget&.first
return unless widget

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def self.signature_overlay_coordinates(pdf_path = TEMPLATE)
end

def self.signature_overlay_coordinates_for(pdf_path)
if Flipper.enabled?(:acroform_debug_logs)
Rails.logger.info("SurivorsBenefits::PdfFill::Va21p534ez HexaPDF template: #{pdf_path}")
Comment thread
RachalCassity marked this conversation as resolved.
Outdated
end
Comment on lines +158 to +160
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logging behavior when the acroform_debug_logs feature flag is enabled lacks test coverage. The existing tests for signature_overlay_coordinates stub the method, which means the new logging code is not exercised. Add tests that verify the logging behavior both when the flag is enabled and disabled, following the pattern established in the codebase for feature flag testing.

Copilot uses AI. Check for mistakes.

HexaPDF::Document.open(pdf_path) do |doc|
field = doc.acro_form&.field_by_name(SIGNATURE_FIELD_NAME)
widget = field&.each_widget&.first
Expand Down
Loading