-
Notifications
You must be signed in to change notification settings - Fork 3
Hotfix for pdf css generation #1209
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
base: staging
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThis PR consolidates PDF handling by removing separate PDF stylesheet compilation, simplifying CSS discovery to use a single application.css file, and adding environment-specific Grover configuration. It also updates the Dockerfile with an additional dependency and cleanup commands to reduce image size. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Pull request overview
This PR fixes PDF generation issues where CSS was causing documents to balloon to 170 pages. The fix simplifies CSS loading by using only the main application.css file instead of attempting to load all CSS files, and removes the separate pdf.scss file that was not being properly utilized.
Changes:
- Simplified build process to only generate application.css, removing pdf.css compilation
- Streamlined CSS loading in PDF layout to read only application.css instead of globbing all CSS files
- Added Chromium-specific configuration for non-development environments in Grover initializer
- Enhanced Docker image with fonts-liberation package and improved cleanup
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| package.json | Removed pdf.css from build:css script, now only builds application.css |
| config/initializers/grover.rb | Refactored options handling and added conditional Chromium executable path and launch args for non-dev environments |
| app/views/layouts/pdf.html.erb | Simplified CSS loading to read only application.css instead of globbing all CSS files |
| app/assets/stylesheets/pdf.scss | Deleted unused PDF-specific stylesheet file |
| Dockerfile | Added fonts-liberation package and cleanup commands to reduce image size |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| end | ||
| end.join("\n") %> | ||
| <% app_css_path = Rails.root.join('app', 'assets', 'builds', 'application.css') %> | ||
| <% css = File.exist?(app_css_path) ? File.read(app_css_path) : '' %> |
Copilot
AI
Jan 17, 2026
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.
The File.read operation is not wrapped in error handling. If the file exists but cannot be read due to permissions or I/O errors, this will raise an exception and break PDF generation. Consider adding a rescue block similar to the error handling that was present in the previous implementation to gracefully handle read failures.
| <% css = File.exist?(app_css_path) ? File.read(app_css_path) : '' %> | |
| <% css = | |
| if File.exist?(app_css_path) | |
| begin | |
| File.read(app_css_path) | |
| rescue StandardError | |
| '' | |
| end | |
| else | |
| '' | |
| end | |
| %> |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## staging #1209 +/- ##
========================================
Coverage 77.08% 77.08%
========================================
Files 54 54
Lines 1370 1370
========================================
Hits 1056 1056
Misses 314 314 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
A pdf is now generated and able to be downloaded however the css did work properly and the document was a 170 pages
Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.