Skip to content
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

Module loading errors during template renderings result in incomplete contents (with status 500) #209

Closed
hkoba opened this issue Jan 14, 2022 · 0 comments
Assignees
Labels

Comments

@hkoba
Copy link
Owner

hkoba commented Jan 14, 2022

SiteApp::call doesn't handle $con->prop->{is_error} case correctly. It can result in incomplete content when
module loading error occurs during template rendering.

Background

YATT::Lite sets $SIG{__DIE__} handler to capture as many errors as possible during its template rendering.
Unfortunately, this does not work well with eval { require MaybeMissingModule } idioms that try to load specified modules.
To solve this problem partially, permissive_require() was introduced in #200. But if you forget it and use plain require() instead, the problem harms you. So, this problem should be solved on another level.

The following codes illustrate the above situation. If you use &yatt:backend(); in templates, a module loading error occurs, and you get incomplete content.

# app.psgi
Entity backend => sub {
  require SomeModule; # instead of YATT::Lite::Util::permissive_require('SomeModule'), which is recommended.
  SomeModule->do_something();
};

# SomeModule.pm
package AnotherModule;

if (eval {require MaybeMissingModule}) {
  MaybeMissingModule->xxx
} else {
  # do fallback
}
@hkoba hkoba added the bug label Jan 14, 2022
@hkoba hkoba self-assigned this Jan 14, 2022
hkoba added a commit that referenced this issue Jan 14, 2022
hkoba added a commit that referenced this issue Jan 14, 2022
hkoba added a commit that referenced this issue Jan 14, 2022
hkoba added a commit that referenced this issue Jan 14, 2022
@hkoba hkoba closed this as completed Jan 14, 2022
hkoba added a commit that referenced this issue Dec 5, 2023
Changelog diff is:

diff --git a/Changes b/Changes
index db7320c..16fb00b 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,17 @@
 Revision history for YATT::Lite

+0.101_103 2023-12-05
+    * GH-214 - Drop use of deprecated `given` syntax
+    * GH-211 - Allow `*.ydo` to reurn PSGI tuple directly
+    * GH-209 - Fix incorrect error of dynamic module loading while rendering
+    * GH-207 - Fix error_response handling for per_role_docroot mode
+    * GH-206 - Fix is_index mis-detection
+    * GH-205 - `&yatt:script_uri;` now cares HTTP_X_FORWARDED_PROTO
+    * GH-204 - (Emacs) fix yatt-mode background face
+    * GH-203 - Allow loading multiple app.psgi in a process
+
+    * Drop perl 5.10
+
 0.101_102 2020-10-17
     * GH-202 - fixed some test failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant