Skip to content

Conversation

@C4ptainCrunch
Copy link
Contributor

@C4ptainCrunch C4ptainCrunch commented Dec 25, 2025

Summary

Fixes DOCHUB-1V7 - Fix ValueError when accessing documents without PDF files

This issue was causing 32,121 errors affecting 411 users when they tried to download documents that don't have a PDF file associated with them.

Changes

  1. documents/views.py:
    • Added check in document_pdf_file view to return 404 if document has no PDF file
    • Added check in document_original_file view to return 404 if document has no original file
  2. catalog/templates/catalog/course.html: Download button now intelligently links to PDF if available, otherwise to original file

Behavior

  • The "Télécharger" button is always visible for all documents
  • If a PDF file exists → downloads the PDF
  • If no PDF file exists → downloads the original file instead
  • If neither file exists → returns a friendly 404 error

Test plan

  • All existing tests pass
  • Added validation to prevent accessing non-existent files
  • Download button provides graceful fallback to original file

Impact

This will fix the Sentry issue and provide a better user experience by always offering a download option, even for documents that haven't been converted to PDF yet.

🤖 Generated with Claude Code

@C4ptainCrunch C4ptainCrunch force-pushed the fix-pdf-download-404 branch 2 times, most recently from ca7c06a to 6634dc9 Compare December 25, 2025 20:56
Fixes DOCHUB-1V7

This issue was causing 32k+ errors with 411 users affected.

Changes:
1. Add check in document_pdf_file view to return 404 if document has no PDF file
2. Add check in document_original_file view to return 404 if document has no original file
3. Update "Télécharger" button to download PDF if available, otherwise download original file

The download button now always appears but intelligently chooses the appropriate file to download.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@C4ptainCrunch C4ptainCrunch merged commit 5fe4505 into main Dec 25, 2025
2 checks passed
@C4ptainCrunch C4ptainCrunch deleted the fix-pdf-download-404 branch December 25, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants