d devhelper

← All errors

Code bug

Errno::ENOENT

No such file or directory @ rb_sysopen - /app/tmp/CommunicationNote_<name>.pdf

v1/medplum_documents#generate_communication_note2 events · 1 users first seen 5 d agolast seen 18 h ago

In one line

The PDF file was never written to tmp, so reading it back failed; the filename is built from the raw patient name, which is not sanitized, and that is the likeliest cause.

Checked against the code

What happened

  • generate_pdf_and_upload builds the filename from the patient name with only whitespace removed.
  • PdfFileGenerator.communication_note_pdf writes to tmp/<filename> and returns the path without checking the file exists.
  • File.binread(path) then raised ENOENT, so no PDF was produced (the name in the path is redacted).
  • Only 2 events for 1 user over 5 days points to a specific patient name or a one-off Prince failure, not a permanent break.

What to do next

  1. Code fix In app/services/medplum/communication_notes.rb, change the patient_name line (line 18) to strip every character that is not a letter, digit, underscore or hyphen: raw_name.gsub(/[^0-9A-Za-z_-]/, ''). Fall back to 'Patient' if the result is blank.
  2. Check In Bugsnag, check the two events' filenames and the Prince stderr or log lines around 2026-11-05 20:59 and 2026-11-10 18:37 UTC. This shows whether the name had special characters or Prince failed to run.

Queries are shown, never run. Check them before using them on production.

Ask a follow-up

Continues the same session, so it still remembers the error and the code it read.

Enter to send · Shift+Enter for a new line
Analysed 1 h ago · claude-sonnet-5-5 · $0.05